简体   繁体   English

强制退出/向上滑动以杀死iOS应用程序而无需点击横幅/警报时如何获取推送通知有效载荷?

[英]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.

相关问题 用户强制退出应用程序时如何处理推送通知? [iOS] - How to handle push notification when app was force-quit by user? [iOS] iOS - 当应用程序强制退出用户时处理静默推送通知 - iOS - Handling Silent Push Notifications When App Is Force-Quit By User 当用户强行退出应用程序时处理iOS的推送通知(替代方法?) - Handling push notifications iOS when app is force-quit by user (Alternatives?) iOS,先强制退出应用程序,点击接收通知横幅后,应用程序启动失败 - iOS, force quit app first, after tapping the receiving notification banner, app launch failed 当app强制退出时如何恢复下载? - How to resume a download when the app force-Quit? 当应用程序未运行或处于后台状态时,如何处理推送通知有效负载而不点击它 - How to handle push notification payload without tapping it when the app is in not running or background state 如果用户强制退出,iOS 会在后台启动我的应用程序吗? - Will iOS launch my app into the background if it was force-quit by the user? iOS:如何在iPhone上触发用户强制退出崩溃? - iOS: how to trigger a user force-quit crash on iPhone? iOS推送通知:当应用程序被终止或迅速终止时如何存储推送通知有效载荷? - iOS push notification: how to store push notification payload when application is kill or terminate in swift? 应用强制退出并重启手机后,无法通过后台通知进行网络通话 - Can't make a network call from background notification after app force-quit and phone restart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM