4

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!");
}
Community
  • 1
  • 1
Mikser
  • 929
  • 10
  • 16
  • Did you already found a solution for this? I'm experiencing the same problem :( – Daan Poron Aug 12 '15 at 12:55
  • No I didn't. I will have to face it sooner or later. The reason I need VoIP notifications is because I need my app to process the data before showing some useful message to the user. Simple notifications that don't trigger any handler before user sees them simply won't work for me. – Mikser Aug 14 '15 at 09:18
  • You people got solution for this? im also facing same issue now. – Anilkumar iOS - ReactNative Jun 21 '16 at 12:28
  • @AnilkumariOSdeveloper , did you get any solution – Kanhaiya Sharma Feb 22 '17 at 08:08
  • Almost 4 years have passed and I thought that things would have changed dramatically and for the good, but no. Currently, In my latest solution I am testing notifications with FCM which works fine on Android. And what about iOS? Well, I was hoping to use FCM for both, but it seems that apple still has this problem with closed apps that simply don't do the background fetch if user swiped the app off. This takes us back to the VoIP notifications, but FCM doesn't support VoIP certificates! Again, 4 years later, iOS notifications are such a pain! – Mikser Mar 28 '19 at 15:20

1 Answers1

0

I did not get any solution but nevertheless I did manage to pass through the requirements with my app and this issue wasn't a big problem. I did get a strong feeling that iOS is designed this way, that if a user shuts down your app, then there should be nothing silent that can start your app even in the background. Of course, I might be wrong, haven't worked with iOS for a long time now, I am sure many things have changed. Please feel free to prove me wrong and describe if there was always an appropriate solution to this present on the iOS platform, or maybe some new ways to solve this problem are available now.

Mikser
  • 929
  • 10
  • 16
  • 1
    This was posted as an answer, but it does not attempt to answer the question. It should possibly be an edit, a comment, another question, or deleted altogether. – herrbischoff Nov 23 '17 at 18:08