如何在应用程序未在后台运行时处理推送通知

时间:2012-08-07 09:58:31

标签: background notifications push apple-push-notifications tray

如果应用不在后台,推送通知就会出现。点击启动按钮不会显示推送通知,它只会打开应用程序,打开推送通知我们必须再次点击通知托盘的推送通知。任何启动方式,我们也可以显示通知吗?

1 个答案:

答案 0 :(得分: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(@" - ");
}