0

推送通知在應用程序處於後臺時不會收到。如果應用程序處於前臺,則它正常工作,如果後臺的應用程序在收到通知後需要啓動某個進程。推送通知在應用程序處於後臺時不會收到使用解析

這裏我的代碼是:

- (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.

回答

0

對於iOS8上,你需要使用下面的委託方法第二:

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

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