iOS设备未使用解析接收推送。有任何想法吗?

时间:2015-01-13 13:35:38

标签: ios parse-platform push-notification pfquery

我正在尝试设置解析以向用户发送推送通知。我的代码似乎没问题,当我发送推送时,所有内容都会编译并在Parse网站上注册了某些内容,但我的手机不会收到任何类型的推送通知。没有。我已经按照解析教程,在我的AppDelegate.m applicationDidFinishLaunching中有:

 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.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = @[ @"global" ];
[currentInstallation saveInBackground];

}

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

我想将推送发送到数组中包含的PFUser:

- (void)pushFriendAtIndex:(NSInteger)index completionHandler:(userCompletionHandler)handler
{
    PFQuery *usernameQuery = [PFUser query];
    [usernameQuery whereKey:@"username" equalTo:[[self.friends objectAtIndex:index] username]];

    PFQuery *pushQuery = [PFInstallation query];
    [pushQuery whereKey:@"user" matchesQuery:usernameQuery];

    NSString *pushMessage = [NSString stringWithFormat:@"From %@",     self.currentUser.username];
    NSDictionary *pushData = @{@"alert": pushMessage, @"badge": @0, @"sound": @"push.wav"};
    PFPush *push = [[PFPush alloc] init];
    [push setQuery:pushQuery];
    [push setData:pushData];
    [push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (error) {
        NSLog(@"Error: %@ %@", error, [error userInfo]);
        handler(NO, error);
    }
    else {
        handler(YES, nil);
    }
}];

}

我已经检查了我的解析帐户页面,并且有:

enter image description here

用户catcat是正确的,因此它正在Parse上注册推送。细分是什么意思?它应该说推送发送给谁?

任何帮助将不胜感激!谢谢!

0 个答案:

没有答案