JeeGee JeeGee - 8 months ago 30
Objective-C Question

App performs task in background (after receiving a remote notification), but finishes not completely

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

It is being called with
content-available = 1
. A download task starts (shows the
), but it does not complete the called task. Only when switching the app back to Foreground it finishes the previous called task.

Any idea... how this can happen?


you have to use perform api call in back ground.

       - (void)applicationDidEnterBackground:(UIApplication *)application {

        isnotificationScreenopen = NO;
        UIBackgroundTaskIdentifier bgTaskId =[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
            [[UIApplication sharedApplication] endBackgroundTask:bgTaskId];
            NSLog(@"%f",[UIApplication sharedApplication].backgroundTimeRemaining);
        NSLog(@"%f",[UIApplication sharedApplication].backgroundTimeRemaining);


you can also read this link also

objective c - Proper use of beginBackgroundTaskWithExpirationHandler