获得苹果公司的远程推送通知,即使在应用程序终止 [英] Get Apple's remote push notifications even after app terminates

查看:267
本文介绍了获得苹果公司的远程推送通知,即使在应用程序终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了在特定的时间间隔收到苹果的远程推送通知的iOS应用。该通知成功接收时,应用程序被激活以及何时应用程序是在后台。但是,当应用从应用切换器/码头终止,通知直到应用程序再次启动接收。

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.

我曾尝试以下code,以保持应用程序活着的背景。同样的code在 applicationWillTerminate实现的:方法,但没有奏效。

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?

推荐答案

如果您主动停止在应用程序切换应用程序它将停止接收任何推送通知。

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.

这篇关于获得苹果公司的远程推送通知,即使在应用程序终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆