Search code examples
iosswiftapn

iOS handle multiple APN when App closed


When my App is closed and I get multiple APNs and click on one of them I do only get the data of the APN I clicked on. All other Notifications disappear.

How do I get the data of the notifications I didn't click on?

I'm currently handling my notifications like this:

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
}

and:

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
        }
    }
}

Also: If I receive notifications and open the app by clicking on the app logo instead of clicking on the notifications, all notifications seem to disappear, too.

Any help would be highly appreciated.


Solution

  • their is no api to get APNs that were NOT delivered to your app.

    in general, APNs make NO delivery guarantees