[英]How to get the push notification payload when force-quit / swipe up to kill the iOS app without tapping on the banner/alert?
I'm building an app which handles notifications pushed from Parse, and trying to create a notification history function. 我正在构建一个处理从Parse推送的通知的应用程序,并尝试创建通知历史记录功能。 I've enabled the background modes successfully, so when the app is running in the background, the app can get the payload well via
application:didReceiveRemoteNotification:fetchCompletionHandler
even the banner/alert is not tapped. 我已经成功启用了后台模式,因此当应用程序在后台运行时,即使未轻按横幅/警报,应用程序也可以通过
application:didReceiveRemoteNotification:fetchCompletionHandler
很好地获取有效负载。 However, when force-quit / swipe up to kill the app, application:didReceiveRemoteNotification:fetchCompletionHandler
is not called. 但是,当强制退出/向上滑动以
application:didReceiveRemoteNotification:fetchCompletionHandler
应用程序时,不会调用application:didReceiveRemoteNotification:fetchCompletionHandler
。
Is there any method to implement for getting the push notification payload when the app is killed without tapping the banner/alert? 有什么方法可以实现在应用程序被杀死而无需点击横幅/警报的情况下获取推送通知有效载荷? Thank you in advance!
先感谢您!
You can't get a notification's payload if your app is killed. 如果您的应用被终止,则无法获得通知的有效负载。
In most cases, the system does not relaunch apps after they are force quit by the user.
在大多数情况下,系统在用户强行退出应用后不会重新启动应用。 One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user.
位置应用程序是一个例外,位置应用程序在iOS 8及更高版本中被用户强行退出后重新启动。 In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system.
但是,在其他情况下,用户必须明确启动应用程序或重新启动设备,然后系统才能将应用程序自动启动到后台。 When password protection is enabled on the device, the system does not launch an app in the background before the user first unlocks the device.
在设备上启用密码保护后,系统不会在用户首次解锁设备之前在后台启动应用程序。 - Understanding When Your App Gets Launched into the Background
- 了解您的应用何时在后台启动
Anyway, push notifications are not reliable . 无论如何,推送通知都不可靠 。
It means that you can not be sure that they will ever be delivered. 这意味着您不能确定它们是否会被交付。
If you want to keep a "notification history" list, do it server-side and fetch it in-app (in a totally not push related way). 如果要保留“通知历史记录”列表,请在服务器端进行处理并在应用程序中获取(完全不与推送相关)。
Each time you send a push notification, keep it's content in database, like any object. 每次发送推式通知时,都将其内容与任何对象一样保留在数据库中。 Then when the user opens the history list, fetch the list like any other parse object.
然后,当用户打开历史记录列表时,像其他解析对象一样获取列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.