class procedure TPlatformBackgroundFetch.performFetchWithCompletionHandler(self: id; _cmd: SEL; application: PUIApplication; completionHandler: id); var LResult: TBackgroundFetchResult; LPlatformResult: NSUInteger; begin if FFetch <> nil then begin // Assume no data LResult := TBackgroundFetchResult.NoData; // Call the handler if assigned FFetch.DoFetch(LResult); LPlatformResult := BackgroundFetchResultToPlatform(LResult); // The completion handler *must* be called, if the app is continue to receive background fetch messages CallBlockImplementation(self, _cmd, completionHandler, LPlatformResult); end; end;
You can also set the fetch interval with setMinimumBackgroundFetchInterval, however you should not that the maximum time amount is 30 seconds.
procedure TPlatformBackgroundFetch.UpdateFetchInterval; begin SharedApplication.setMinimumBackgroundFetchInterval(CocoaDoubleConst(libUIKit, 'UIApplicationBackgroundFetchIntervalMinimum')); end;
The demo project implements the background fetch as a platform service (makes use of TPlatformServices), it sets the OnFetch handler, and you have to provide an implementation for it.
Head over and check out the demo for Background Fetches for FireMonkey in Delphi 10 Berlin on IOS.
Mirror: Download the background fetch demo project for FireMonkey in Delphi on iOS