简体   繁体   中英

Is it possible to read all push notification in ios?

I want to read all the notifications related to my app which are all displayed in the notification center while opening the app. Please suggest me any idea. i tried,

 UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

but it returning only one selected notification.

[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey] will return the notification that caused your application to start.
So if you'll receive push notification, and open application from SpiringBoard, then [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey] will be nil .
This means if user doesn't open application using push notification, then application will not know about received push notification.

So the answer is - there is no way.

EDIT:
Basically if you are using local notifications, you can save scheduled notifications ( [UIApplication scheduledLocalNotifications] ) into file/server, and then compare scheduled notifications with your saved file. In this case you will know which notifications are delivered.

You cannot read all the waiting notifications locally on the iOS device. You can be sent the info on the selected one if the user selects one to open the app. (with your shown code)

Generally, what you want to do is maintain a list of a sent notifications tied to device id on your server (you should already have this because it is needed to send the notifications. You will need to query your server to get the list of sent notifications to show in your app.

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