iOS - 当应用程序被杀死时处理静默推送通知 [英] iOS - Handling Silent Push Notifications When App Is Killed

查看:272
本文介绍了iOS - 当应用程序被杀死时处理静默推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在 iOS 中遇到推送通知问题.

I am currently facing a problem with push notifications in iOS.

我的应用接收包含标识符的静默推送通知.然后使用此标识符从创建本地通知的远程服务器获取数据.

My app receives silent push notifications containing an identifier. This identifier is then used to fetch data from a remote server from which a local notification is created.

据我所知,如果用户强制退出应用程序(即通过双击主页按钮并滑动关闭应用程序),则无提示推送通知不会传递到 AppDelegate 中的 didReceiveRemoteNotification 方法类 [1] [2],从而阻止应用进行任何类型的处理.

As far as I'm aware, if the user has force-quit an app (i.e. by double tapping the home button and swipe closing the app) then the silent push notification does not get passed onto the didReceiveRemoteNotification method in the AppDelegate class [1] [2], thus preventing the app from doing any kind of processing.

我对处理上述情况进行了大量研究.但是,无法找到明确的答案,希望有人能帮助我或为我指明正确的方向.

I have done a fair amount of research into handling the situation mentioned above. However, was unable to find a definitive answer and was hoping someone could help me out or point me in the right direction.

推荐答案

如文档所示 - application:didReceiveRemoteNotification:fetchCompletionHandler: 由 Apple 提供,您无能为力:

As documented - application:didReceiveRemoteNotification:fetchCompletionHandler: by Apple, there is not much you can do:

但是,如果用户强制退出,系统不会自动启动您的应用.在这种情况下,用户必须重新启动您的应用或重新启动设备,然后系统才会再次尝试自动启动您的应用.

However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

这样做是为了让用户可以停止不需要的通知

It is done so that users could stop unwanted notifications

这篇关于iOS - 当应用程序被杀死时处理静默推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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