-(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 NSLogs
), 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 UIBackgroundTaskIdentifier.to 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