I have a background job that runs every 7 hours, it makes an API call that take approximately 1-3 seconds. Looking at the battery section of the setting itβs showing that the job has been running in the background for 40 minutes in the past 20 hours.
simulating background fetch works just fine, and calls completion within seconds.
Any idea why it's running for too long?
NSTimeInterval backgroundFetchTimeInterval = 7 * 3600;
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:backgroundFetchTimeInterval];
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[[SyncManager sharedManager] performSyncWithCompletion:^(NSArray *results, NSError *error) {
if (error) {
completionHandler(UIBackgroundFetchResultFailed);
}
else {
if (resultCount > 0) {
completionHandler(UIBackgroundFetchResultNewData);
}
else {
completionHandler(UIBackgroundFetchResultNoData);
}
}
}];
}