当我的应用程序关闭并且我获得多个 APN 并单击其中一个时,我只会获得我单击的 APN 的数据。所有其他通知都会消失。
如何获取我没有点击的通知的数据?
我目前正在处理这样的通知:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let type: UIUserNotificationType = [UIUserNotificationType.Badge, UIUserNotificationType.Alert, UIUserNotificationType.Sound]
let setting = UIUserNotificationSettings(forTypes: type, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(setting)
UIApplication.sharedApplication().registerForRemoteNotifications()
if let remoteNotification = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary{
self.application(application, didReceiveRemoteNotification: remoteNotification as [NSObject : AnyObject])
}
return true
}
和:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){
if let aps = userInfo["aps"] as? NSDictionary {
if let alert = aps["alert"] as? NSDictionary {
if let message = alert["message"] as? NSString {
//handle push message
}
} else if let alert = aps["alert"] as? NSString {
//handle push message
}
}
}
另外:如果我收到通知并通过单击应用程序徽标而不是单击通知来打开应用程序,所有通知似乎也会消失。
任何帮助将不胜感激。