使用解析在应用程序处于后台时推送通知未收到

时间:2015-03-02 06:02:46

标签: objective-c background parse-platform xcode6 apple-push-notifications

当app在后台时,推送通知没有收到。如果应用程序在前台,它工作正常,如果收到通知后的应用程序需要启动某个过程。

我的代码是:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [PFPush handlePush:userInfo];
     if (application.applicationState == UIApplicationStateInactive)
    {
       NSLog(@" background userInfo =%@",userInfo);

        [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];
    }

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

    NSLog(@"%@",userInfo);

}

我的环境:iOS8,Xcode 6.3,Mac10.10.

1 个答案:

答案 0 :(得分:0)

对于iOS8,您需要使用以下第二种委托方法:

// < iOS7
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

// >= iOS7
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler