通过REST api解析推送通知不会发送到iOS设备

时间:2015-11-10 05:22:10

标签: ios rest parse-platform push-notification

我无法通过REST api通过以下程序接收iOS设备的推送通知。

  1. 像这样注册的iOS设备令牌

    - (void)setupParseWithApplication:(UIApplication *)application {
        [Parse setApplicationId:PARSE_APP_ID
                      clientKey:PARSE_CLIENT_KEY];
        // Register for Push Notitications
        if(isOSLessThan(@"8.0")) {
            UIRemoteNotificationType remoteNotificationTypes = (UIRemoteNotificationTypeAlert |
                                                                UIRemoteNotificationTypeBadge |
                                                                UIRemoteNotificationTypeSound);
            [application registerForRemoteNotificationTypes:remoteNotificationTypes];
        } else {
            UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                            UIUserNotificationTypeBadge |
                                                            UIUserNotificationTypeSound);
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                                     categories:nil];
            [application registerUserNotificationSettings:settings];
            [application registerForRemoteNotifications];
        }
    }
    
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        // Store the deviceToken in the current installation and save it to Parse.
        NSLog(@"%@", deviceToken.description);
        PFInstallation *currentInstallation = [PFInstallation currentInstallation];
        [currentInstallation setDeviceTokenFromData:deviceToken];
        currentInstallation.channels = @[ @"global" ];
    
        [[currentInstallation saveInBackground] continueWithSuccessBlock:^id(BFTask *task) {
            NSLog(@"%@", task.result);
            return task;
        }];
    }
    
  2. 使用REST api

  3. #/bin/sh curl -X POST \ -H "X-Parse-Application-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ -H "X-Parse-REST-API-Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ -H "Content-Type: application/json" \ -d '{ "where": { "deviceToken": { "$in": [ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" (device token obtained in 1, space and <> are removed) ] } }, "data": { "alert": "Push", "badge": "Increment" } }' \ https://api.parse.com/1/push

    如上所述,推送通知日志在附加的Parse控制台中保留,但未发送此推送通知。 你能告诉我这个程序有什么问题吗?

0 个答案:

没有答案