当应用程序不在后台运行时如何处理推送通知
Posted
技术标签:
【中文标题】当应用程序不在后台运行时如何处理推送通知【英文标题】:How to handle Push notification when app is not in running in background 【发布时间】:2012-08-07 09:58:30 【问题描述】:如果应用不在后台,推送通知来了。单击启动按钮不会显示推送通知,它只会打开应用程序,要打开该推送通知,我们必须再次点击通知托盘中的推送通知。任何启动方式我们也可以显示通知?
【问题讨论】:
已解决。请参阅:***.com/questions/4782352/… 【参考方案1】:已解决。答案是:
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
NSDictionary *tmpDic = [launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
//if tmpDic is not nil, then your app is launched due to an APNs push, therefore check this NSDictionary for further information
if (tmpDic != nil)
NSLog(@" - launch options dict has something ");
NSLog(@" - badge number is %@ ", [[tmpDic objectForKey:@"aps"] objectForKey:@"badge"]);
NSLog(@" - ");
【讨论】:
以上是关于当应用程序不在后台运行时如何处理推送通知的主要内容,如果未能解决你的问题,请参考以下文章
应用关闭时如何处理 UNNotificationAction?