I am currently building an app that utilizes iOS 7's Silent Push Notifications to wake the app in background on request.
As I would do in -applicationDidEnterBackground:
I initiated a background task in -application:didReceiveRemoteNotification:fetchCompletionHandler:
which looks like this:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
self.taskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:self.taskId];
self.taskId = UIBackgroundTaskInvalid;
completionHandler(UIBackgroundFetchResultNewData);
}];
}
While the app successfully registers for remote notifications and -application:didReceiveRemoteNotification:fetchCompletionHandler:
is called on notification arrival, the app stays in background for just few seconds before returning to suspended state, much shorter than expected execution time given (when called in -applicationDidEnterBackground:
) which I believe is around 3 minutes.
Is this an expected behaviour? Or is it not possible using remote notifications?