使用用于IOS的Parse SDK推送未在设备中交付

使用用于IOS的Parse SDK推送未在设备中交付,ios,objective-c,xcode,parse-platform,push-notification,Ios,Objective C,Xcode,Parse Platform,Push Notification,我正在使用parse SDK向朋友发送推送通知。 注意:我已经使用SimpleRESTAPI手动测试了推送通知证书,它在那里工作 使用以下代码: 我在安装表中有,通道是阵列类型,其中我有匹配键: 它在解析表中显示了delever,但我的设备没有收到任何类型的通知(查看附加的屏幕截图) 我的委托设置: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)laun

我正在使用parse SDK向朋友发送推送通知。 注意:我已经使用SimpleRESTAPI手动测试了推送通知证书,它在那里工作

使用以下代码: 我在安装表中有,通道是阵列类型,其中我有匹配键: 它在解析表中显示了delever,但我的设备没有收到任何类型的通知(查看附加的屏幕截图)

我的委托设置:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Uncomment and fill in with your Parse credentials:
    [Parse setApplicationId:@“MY APP ID
                  clientKey:@“MY CLIENT KEY”];

   // Override point for customization after application launch.
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];

}



- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken {
    PFInstallation *currentInstallation = [PFInstallation currentInstallation];
    [currentInstallation setDeviceTokenFromData:newDeviceToken];
    currentInstallation.channels = @[@“channel”];
    [currentInstallation saveInBackground];


   }


- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    if (error.code == 3010) {
        //NSLog(@"Push notifications are not supported in the iOS Simulator.");
    } else {
        // show some alert or otherwise handle the failure to register.
        //NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error);
    }
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [PFPush handlePush:userInfo];


}

//NOTE: after login i change the channels value in installation table by 

   PFInstallation *currentInstallation = [PFInstallation currentInstallation];
       // [currentInstallation setDeviceTokenFromData:newDeviceToken];

        NSString *string=[NSString stringWithFormat:@"channel%@",[PFUser currentUser]];
        NSArray *array=[NSArray arrayWithObjects:string, nil];
        currentInstallation.channels =array;
        [currentInstallation saveInBackground];


更新:使用针对IOS 8的新Parse SDK,我的问题已得到解决

如果您的设备运行IOS 8,请注意,
registerForRemoteNotificationTypes
不再受支持

您需要使用注册表通知设置。下面是一个应在iOS 7(及以下版本)和iOS 8上运行的示例代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

    // Checks for iOS 8
    if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)) {

           [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

           [application registerForRemoteNotifications];

    } else {

          [application registerForRemoteNotificationTypes:
                     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];

    }

    // The rest of your didFinishLaunchingWithOptions: method should be here

    return YES;
}

编辑:我刚才看到您说它与RESTAPI一起工作,所以这不会引起您的问题。不过,将代码更新到这一点是一件好事,因为iOS 8设备可能会遇到问题


编辑2:

问题可能来自您的解析项目配置。您需要手动启用“客户端推送通知”。默认情况下,Parse禁用它,这将阻止Parse SDK发送推送通知


转到Parse.com,在推送部分中查看应用程序的设置,并将“客户端推送已启用?”设置为“是”。

您是否已在Parse.com中检查示例。只需添加您的应用程序[Parse]

setApplicationId:@“MY APP ID
                  clientKey:@“MY CLIENT KEY”]; 
然后运行并检查其工作情况,如果不工作,则表示您在工作中犯了一些错误

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // ****************************************************************************

  [Parse setApplicationId:@"NlQEPXWSQgueodgfbuogbSQdF0MOzMPdvyBSvvH5sCbF2rpAW8JK" clientKey:@"qJTAqgFHck1a2TfjskfjvjfvkhhGsqycfhWgQhmnPWcNKAgGt1p"];
    // ****************************************************************************

    // Override point for customization after application launch.
    [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];

    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    [self.window makeKeyAndVisible];
    return YES;
}
并签入您的代码。您的设备正常运行

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

        NSLog(@"device token===%@",deviceToken);


        PFInstallation *currentInstallation = [PFInstallation currentInstallation];
        [currentInstallation setDeviceTokenFromData:deviceToken];
        currentInstallation.channels = @[@"global"];
        [currentInstallation saveInBackground];
    }![appkey][1]


谢谢您的快速回答,但我已经启用了,请查看附带的显示parse sdk推送的图片。我可以为您提供推送键以便您可以签入示例代码吗?感谢体育,向上投票寻求帮助,通过使用IOS 8 sdk进行解析解决了问题。
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

        NSLog(@"device token===%@",deviceToken);


        PFInstallation *currentInstallation = [PFInstallation currentInstallation];
        [currentInstallation setDeviceTokenFromData:deviceToken];
        currentInstallation.channels = @[@"global"];
        [currentInstallation saveInBackground];
    }![appkey][1]