简体   繁体   中英

Read all push notifications available in the notification bar in iOS

The user force killed the application and then receives 3 push notifications from the server. When clicking on the push notification, the application will relaunch.

Is it possible to read user info dictionary of all push notifications available in the notification bar for that particular application?

No, it is not possible. You need to implement a web service. The web service will provide all unread notifications.

Yes it is possible to read the push notification by clicking it from the navigation controller.

First of all when application is open it comes in didFinishLaunching method. And if you trying to open application from the navigation push notification click then you can get the notification in launchOptions variable. It contains the dictionary regarding the Pushnotification.

You can find it by below code.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
    NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];

    if(apsInfo) {
        //there is some pending push notification, so do something
    }
}

If your application isn't running then only the notification that the user actually tapped on will be delivered to your application in didFinishLaunchingWithOptions . The content of the other notifications is not available.

If the user launches your application from the app icon rather than from the notification then no notification information is available.

Your app should retrieve any updates whenever it is launched, regardless of the availability of notification data in didFinishLaunchingWithOptions . The presence of notification data should act as a hint as to the behaviour the user is expecting from your app (for example, if they tapped a notification that they had received a message from a specific user they would probably expect the app to open to that message).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM