My iOS application successfully receives VoIP push notifications even if it is closed, thanks to PushKit. There is only one condition when it fails:
If I swipe my app out(terminate) throught the standard task switcher AND reboot my device.
At first, I had this problem simply after rebooting the device, as described in this question: Troubleshooting post-boot push notification delivery failures A background task hack helped me, many thanks to the author, too bad I couldn't add any score.
Now I am stuck with this problem. Notifications won't arrive because didFinishLaunchingWithOptions
is simply not called at device boot up if user terminated the app before rebooting his/her device.
my app's background capabilities that are checked:
- Voice over IP
- Remote notifications
here's my code snippet:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
pushRegistry.delegate = self;
pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask];
self.backgroundTask = UIBackgroundTaskInvalid;
}];
return YES;
}
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask];
self.backgroundTask = UIBackgroundTaskInvalid;
NSLog(@"Push token received, probably!");
}