简体   繁体   English

是否有可能在ios中读取所有推送通知?

[英]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. [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]将返回导致您的应用程序启动的通知。
So if you'll receive push notification, and open application from SpiringBoard, then [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey] will be nil . 因此,如果您将收到推送通知,并从SpiringBoard打开应用程序,则[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]将为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. 基本上,如果您使用的是本地通知,则可以将计划的通知( [UIApplication scheduledLocalNotifications] )保存到文件/服务器中,然后将计划的通知与保存的文件进行比较。 In this case you will know which notifications are delivered. 在这种情况下,您将知道传递了哪些通知。

You cannot read all the waiting notifications locally on the iOS device. 您无法在iOS设备上本地阅读所有等待通知。 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. 通常,您要做的是维护与服务器上的设备ID绑定的已发送通知的列表(您应该已经有此列表,因为发送通知需要使用该ID。您将需要查询服务器以获取已发送列表。通知显示在您的应用中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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