我可以获得有关通知 (apn) 的信息吗

发布于 2024-12-23 00:58:42 字数 477 浏览 2 评论 0原文

当应用程序从后台模式变为前台模式时,我可以获得应用程序的推送通知(APNS 通知)列表吗? 在前台模式我可以在回调中接收有关推送通知的信息

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

其他情况:

当应用处于后台模式时,我的应用会收到推送通知。 之后,我单击应用程序图标,我想获取有关收到通知的信息。我怎样才能得到这个信息?

如果我在后台模式下直接单击通知(而不是应用程序图标),则会调用回调didReceiveRemoteNotification

Can I get list of push notifications (APNS notifications) for my app when app became from background to foreground mode?
In foreground mode i can receive info about push notification in callback

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

Other case:

My app receive push notification, when app in background mode.
After this i click on app icon, and i want to get info about received notification. How can i get this info?

If i click directly on the notification (not on app icon), in background mode, then callback didReceiveRemoteNotification is call.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月棠 2024-12-30 00:58:42

当应用程序从后台模式变为前台模式时,我可以获得应用程序的推送通知(APNS 通知)列表吗?

没有。没有清单。您一次只能收到一份通知。当用户的 iPhone 处于离线状态并且您发送了 5 条通知时,用户将只会收到您发送的最后一条通知。

如果用户使用通知上的打开操作启动您的应用程序,您将在开始使用时收到它:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

其他情况

当应用程序处于后台模式时,我的应用程序会收到推送通知。之后,我单击应用程序图标,我想获取有关收到通知的信息。我怎样才能得到这些信息?

你不能。当用户关闭通知并稍后打开您的应用程序时,它已经消失并且无法访问它。

当您发送推送通知时,您可能有一个可通过互联网访问的服务器,您可以在其中注册用户的设备。

处理此问题的常用方法是将通知存储在此服务器上并在应用程序启动时查询它...因此,使用通知只是为了通知用户启动您的应用程序,然后在应用程序启动时检查您的服务器是否有您想要的内容。

Can I get list of push notifications (APNS notifications) for my app when app became from background to foreground mode?

No. There is no list. You can only get one notification at once. When the users iPhone is offline and you send 5 notifications the user will only get the last one you have send.

If the user starts your app using the open action on the notification you will get it on start using:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Other Case

My app receive push notification, when app in background mode. After this i click on app icon, and i want to get info about received notification. How can i get this info?

You can't. When the user closes the notification and opens you app later it is already gone and there is no way to access it.

When you send push notifications you probably have a server reachable over the internet, where you register the devices of the user.

The usual way to handle this is to store the notifications on this server and query it on app launch... so use the notification just to notify the user to start your app and then check your server on launch of the app for whatever you want.

淡淡の花香 2024-12-30 00:58:42

一旦您的应用程序到达前台并主动运行,通知警报(如声音、警报)将不会显示,或者您不会收到通知。

但是您将在 UIApplication Delegate 中收到回调,表明您可以使用它。

API 是,

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;

而且,如果您的应用程序在后台运行,则会出现通知,并且仅当您单击“查看”按钮时,您才会在 UIApplication 委托中收到回调。

如果您单击“关闭”按钮,您将不会在应用程序中收到回电。

Once your application reaches foreground and actively running, the notification alerts like sound, alert won't be displayed or you wont be notified.

But you will get a call back in the UIApplication Delegate that you can make use of it.

The api is,

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;

And, if your application is running in background, then the notification appears and only when you click on "View" button, you will get the call back in UIApplication delegate.

If you click on Close button, you won't get the call back in the application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文