Get Apple's remote push notifications even after app terminates

倖福魔咒の 提交于 2020-01-20 08:18:27

问题


I am developing an iOS app which receives apple's remote push notifications at a particular time interval. The notifications are received successfully when app is active as well as when app is in background. But when app is terminated from app switcher/dock, notifications are not received until the app is started again.

I have tried following code to keep app alive in background. This same code is implemented in applicationWillTerminate: method, but it did not work.

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

What is the perfect way of receiving notifications even after app is terminated?


回答1:


If you actively stop the app in the app switcher it stops receiving any push notifications.

This is an intended behaviour as stated by Apple engineers in the developer forums.



来源:https://stackoverflow.com/questions/25176066/get-apples-remote-push-notifications-even-after-app-terminates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!