![](/img/trans.png)
[英]How to get the push notification payload when force-quit / swipe up to kill the iOS app without tapping on the banner/alert?
[英]iOS push notification: how to store push notification payload when application is kill or terminate in swift?
我正在使用 firebase 发送多个推送通知。 我的应用程序收到所有通知。 现在如何在应用程序被终止或终止时将所有推送通知数据存储在用户默认值中? 当应用程序被终止并且用户从所有通知中单击一个推送通知时,如何存储所有推送通知数据?
您的应用程序不会仅通过推送通知被调用。 您在通知托盘中收到的内容由 iOS 直接处理,推送通知的内容,特别是通知正文的 aps 键内的内容用于填充您在通知托盘中看到的内容。
如果应用程序处于挂起或终止状态,则不会因为您收到推送通知而调用该应用程序。 当然,除非您的 apns-push-type 设置为 background 并且 content-available = 1 在您的通知中。 电话将转到
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
您可以在何处根据应用程序的要求处理内容。
要检测应用程序是否从通知启动,
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
if let dict = launchingOptions?[.remoteNotification]{
//App launched from Notification
if let userInfo = dict as? [AnyHashable:Any]{
//Do what your app requires with the notification using the userInfo.
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.