当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.
答案 0 :(得分:0)
对于iOS8,您需要使用以下第二种委托方法:
// < iOS7
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
// >= iOS7
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler