Receive remote Apple push notifications even after app termination

I am developing an iOS app that receives Apple remote push notifications for a specific amount of time. Notifications are received successfully when the app is active and also when the app is in the background. But when the app is terminated by the switcher / dock app, notifications are not received until the app is launched again.

I have tried the following code to keep the application in the background. The same code is implemented in the method applicationWillTerminate:

, but it doesn't work.

__block UIBackgroundTaskIdentifier bgTask ;
    UIApplication  *app = [UIApplication sharedApplication];
    bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:bgTask];
        [app enabledRemoteNotificationTypes];
        bgTask = UIBackgroundTaskInvalid;
    }];

      

What is the ideal way to receive notifications even after the application ends?

+3


source to share


1 answer


If you actively stop an app in the App Switcher, it stops receiving any push notifications.



This is intentional behavior reported by Apple engineers in the developer forums.

+3


source







All Articles