APNS得到所有推送通知 [英] APNS get all push notifications

查看:227
本文介绍了APNS得到所有推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器将推动一个通知,当用户开始跟随或交涉。

The server will push a notification when the user start to follow or nego.

- (无效)申请:(的UIApplication *)应用didReceiveRemoteNotification:(NSDictionary的*)USERINFO 时通知用户水龙头,此块将被执行,而我将获得通知信息。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo when the user tap on the notification, this block will be executed, and I will get the notification info.

目前我面临一个问题,当有超过1通知推,当用户敲击在第一之一,然后在第二1韩元 T为执行。有时用户不要拍打在通知中心通知的项目,而是直接打开应用程序,那么 - (无效)应用:(*的UIApplication)的应用didReceiveRemoteNotification:(NSDictionary的*)USERINFO 完全不执行。

Currently I'm facing a problem, when there are more than 1 notification being pushed, when the user tap on the first one, then the second one won't be executed. Sometime user don't tap on the notification item in notification centre, but open the app directly, then - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo totally not executed.

有没有办法让所有通知,这样我可以存储信息到 NSUserDefaults的

Is there any way to get ALL notifications so that I can store the info into NSUserDefaults?

推荐答案

案例1:

当应用程序不在内存中(无论是在背景模式还是在前台模式),用户有两种选择

When the app is not in memory(neither in background mode nor in foreground mode) the user has two choices


  1. 无论是通过点击收到的通知打开应用程序

  1. either open the app by clicking on the notification received

或直接通过点击应用程序图标打开应用程序

or open the app directly by clicking on the app icon

在这些情况下

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

被称为在那里你可以得到通知(如果有的话)在使用本

is called where you can get the notification (if any) using this

NSDictionary* remoteNotification=[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

案例2:

但是,当应用程序是无论是在后台或前台模式,然后

But when the app is either in background or in foreground mode, then

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

被执行,所以你可以收到通知就获取你的数据。
如果在这些模式中还用户尝试单击通知然后再

is executed, so there you can fetch your data with respect to the notification received. And if in these modes also user tries to click on the notification then again

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

被调用,那里你可以在个案1处理这样的通知数据。

is called and there you can handle the notification data like in Case 1.

希望这会有所帮助。

这篇关于APNS得到所有推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆