Parse platform 使用Parse.com在iOS 8中推送通知不起作用

Parse platform 使用Parse.com在iOS 8中推送通知不起作用,parse-platform,push,ios8,Parse Platform,Push,Ios8,我有一个在iOS 7中工作的代码,我收到所有推送通知 当使用Parse.com实现新的iOS 8推送通知时,我无法让它工作 代码如下: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions // Register for push notifications [Parse setApplication

我有一个在iOS 7中工作的代码,我收到所有推送通知

当使用Parse.com实现新的iOS 8推送通知时,我无法让它工作

代码如下:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions     
    // Register for push notifications
    [Parse setApplicationId:@"XXXX" clientKey:@"XXX"]; // REMOVED IDS FOR SECURITY REAS

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {

        UIMutableUserNotificationAction *viewAction = [[UIMutableUserNotificationAction alloc] init];
        viewAction.identifier = @"medphone-view";
        viewAction.title = @"Ver";
        viewAction.activationMode = UIUserNotificationActivationModeForeground;
        viewAction.destructive = NO;

        UIMutableUserNotificationAction *dismissAction = [[UIMutableUserNotificationAction alloc] init];
        dismissAction.identifier = @"medphone-dismiss";
        dismissAction.title = @"Excluir";
        dismissAction.activationMode = UIUserNotificationActivationModeBackground;
        dismissAction.destructive = YES;

        UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc] init];
        category.identifier = @"medphone";
        [category setActions:[NSArray arrayWithObjects:viewAction, dismissAction, nil] forContext:UIUserNotificationActionContextDefault];

        NSSet *categories = [NSSet setWithObjects:category, nil];

        UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
        UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:categories];
        [application registerUserNotificationSettings:mySettings];
        [application registerForRemoteNotifications];

    } else {
        [application registerForRemoteNotificationTypes:
         UIRemoteNotificationTypeBadge |
         UIRemoteNotificationTypeAlert |
         UIRemoteNotificationTypeSound];
    }

    if (launchOptions) { //launchOptions is not nil
        NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
        NSLog(@"Push info %@", userInfo);
        NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];

        if (apsInfo) { //apsInfo is not nil
            NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
            [prefs setValue:userInfo forKey:@"PUSHDATA"];
            [prefs setBool:YES forKey:@"PUSH"];
            [prefs synchronize];
            NSLog(@"entrou no UIApplicationLaunchOptionsRemoteNotificationKey %@", apsInfo);
        }
    }

    return YES;
}

And these other methods:

    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    PFInstallation *currentInstallation = [PFInstallation currentInstallation];
    [currentInstallation setDeviceTokenFromData:deviceToken];
    currentInstallation.channels = @[@"global"];
    [currentInstallation saveInBackground];
}

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:userInfo];
    NSLog(@"entrou no didReceiveRemoteNotification %@", userInfo);
}

#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
    //register to receive notifications
    [application registerForRemoteNotifications];
}

    - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler {
    NSLog(@"entrou no UIApplicationLaunchOptionsRemoteNotificationKey %@", userInfo);

    //handle the actions
    if ([identifier isEqualToString:@"medphone-view"]) {
        NSLog(@"ver");
    } else if ([identifier isEqualToString:@"medphone-dismiss"]) {
        NSLog(@"dismmis");
    }
    completionHandler();
}



#endif
我做错什么了吗?有效负载是正确的,因为它在iOS 7上工作。并设置了类别


请让我知道

iOS 8的代码已更改:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{ [[UIApplication sharedApplication] registerUserNotificationSettings:
   [UIUserNotificationSettings settingsForTypes:
                  (UIUserNotificationTypeSound | 
                   UIUserNotificationTypeAlert | 
                    UIUserNotificationTypeBadge) categories:nil]];

    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | 
      UIUserNotificationTypeSound | 
      UIUserNotificationTypeAlert)];
}

iOS 8的代码已更改:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{ [[UIApplication sharedApplication] registerUserNotificationSettings:
   [UIUserNotificationSettings settingsForTypes:
                  (UIUserNotificationTypeSound | 
                   UIUserNotificationTypeAlert | 
                    UIUserNotificationTypeBadge) categories:nil]];

    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | 
      UIUserNotificationTypeSound | 
      UIUserNotificationTypeAlert)];
}

iOS 8的代码已更改:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{ [[UIApplication sharedApplication] registerUserNotificationSettings:
   [UIUserNotificationSettings settingsForTypes:
                  (UIUserNotificationTypeSound | 
                   UIUserNotificationTypeAlert | 
                    UIUserNotificationTypeBadge) categories:nil]];

    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | 
      UIUserNotificationTypeSound | 
      UIUserNotificationTypeAlert)];
}

iOS 8的代码已更改:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{ [[UIApplication sharedApplication] registerUserNotificationSettings:
   [UIUserNotificationSettings settingsForTypes:
                  (UIUserNotificationTypeSound | 
                   UIUserNotificationTypeAlert | 
                    UIUserNotificationTypeBadge) categories:nil]];

    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | 
      UIUserNotificationTypeSound | 
      UIUserNotificationTypeAlert)];
}

你把你的应用程序证书上传到Parse.com了吗?当你说不能让它工作时,你看到了什么问题?通知是否未显示在设备上?另外,请看一下:-文档刚刚更新以描述类别支持。我看到了相同的问题-当我检查安装时,deviceToken未设置。您是否将应用程序证书上载到Parse.com?当您说无法使其工作时,您看到了什么问题?通知是否未显示在设备上?另外,请看一下:-文档刚刚更新以描述类别支持。我看到了相同的问题-当我检查安装时,deviceToken未设置。您是否将应用程序证书上载到Parse.com?当您说无法使其工作时,您看到了什么问题?通知是否未显示在设备上?另外,请看一下:-文档刚刚更新以描述类别支持。我看到了相同的问题-当我检查安装时,deviceToken未设置。您是否将应用程序证书上载到Parse.com?当您说无法使其工作时,您看到了什么问题?通知是否未显示在设备上?还可以看一看:-文档刚刚更新以描述类别支持。我看到了相同的问题-当我检查安装时,deviceToken没有设置