Using completeHandler (UIBackgroundFetchResultNewData) when updating background in iOS

I am using background update in my application. To test the application, I have this in my AppDelegate.m:

-(void)application:(UIApplication *)application
performFetchWithCompletionHandler:
(void (^)(UIBackgroundFetchResult))completionHandler {



    NSLog(@"did a background refresh");
    completionHandler(UIBackgroundFetchResultNewData);



}

I tested it on a simulator and it works great. I'm not sure what to use. completionHandler(UIBackgroundFetchResultNewData);Why do I need it and why can I use it? I understand that this could be:

UIBackgroundFetchResult.NewData - Called when new content has been fetched, and the application has been updated.
UIBackgroundFetchResult.NoData - Called when the fetch for new content went through, but no content is available.
UIBackgroundFetchResult.Failed - Useful for error handling, this is called when the fetch was unable to go through.

However, I do not understand why I should call it and how useful it is. Any pointers to this would be really appreciated. Thank!

+4
source share
1 answer

You have to call this so that iOS knows what the result of your background fetch is. He uses this information to plan future background images.

, .

.

. .

+5

All Articles