处理推送通知时,应用程序没有运行程序(App被杀害) [英] Handling push notifications when app is not running (App is Killed)

查看:134
本文介绍了处理推送通知时,应用程序没有运行程序(App被杀害)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题似乎是重复的<一个href=\"http://stackoverflow.com/questions/12116282/handling-push-notifications-when-app-is-not-running\">this 之一,但它不是。当应用程序被杀害并在后台没有运行,如果我收到推送通知,并点击该通知的旗帜,它工作正常。 用户信息不为空并且应用程序处理通知。 BUT 如果我解雇通知的旗帜,并通过点击应用程序图标打开应用程序,这种用户信息返回nil。

My problem seems to be duplicate of this one,but it's not. While application is killed and not running in the background, if I receive push notification and clicked the notification banner, it works fine. "userInfo" isn't empty and application handles the notification. BUT if i dismiss the notification banner and open the app via clicking the application icon, this "userInfo" returns nil.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions {
    NSDictionary* userInfo = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if(userInfo != nil){
        //Handling notification

    }
}

和也

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
    if([application applicationState] == UIApplicationStateActive)    {
         NSLog(@"...1");

    }else if([application applicationState] == UIApplicationStateInactive){
         NSLog(@"...2");

    }else if([application applicationState] == UIApplicationStateBackground){
         NSLog(@"...2");

    }
    completionHandler(UIBackgroundFetchResultNoData);
}

有什么办法来处理这​​些通知,或者我应该用我自己的处理?

Is there any way to handle these notifications or should I handle them by my own ?

推荐答案

没有您的应用程序只了解用于打开/启动应用程序的通知。

No your app is only informed about the notification that is used to open/launch your app.

有没有办法检测有在通知中心,为您的应用程序的任何通知。您需要在您的应用程序服务器,以这个自己搭建。

There is no way to detect of there are any notification in the notification center for your app. You need to build this yourself in your apps server.

这篇关于处理推送通知时,应用程序没有运行程序(App被杀害)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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