我正在使用Firebase发送多个推送通知。我的应用程序收到所有通知。现在,当应用程序被终止或终止时,如何在用户默认状态下存储所有推送通知数据?当应用程序被杀死并且用户从所有通知中单击一个推送通知时,如何存储所有推送通知数据?
您的应用不会仅通过推送通知被调用。在通知托盘中收到的内容将直接由iOS处理,而推送通知的内容(特别是通知主体的aps键内部的内容)将用于填充在通知托盘中看到的内容。
仅当您处于暂停或终止状态时,您才会收到推送通知,因此该应用不会被调用。当然,除非您在通知中将apns-push-type设置为背景且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.
}
}
}