突然,parse.com停止为我的应用程序的一个部分提供推送通知

时间:2014-09-27 03:48:03

标签: ios notifications parse-platform push

我的应用程序中有两个部分,用户通过推送通知发送邀请,如朋友请求,并在某个地点见面,一切都运行良好数月,但本周突然用户邀请朋友见面的部分一个位置停止提供推送通知,而朋友请求的另一部分工作正常,我没有改变任何代码,我检查证书和一切都很好,因为它发送的应用程序和接收推送通知。 通知由解析接收,但未传送到设备。

这是工作部分的代码:

PFQuery *pushQuery = [PFInstallation query];
                    [pushQuery whereKey:@"user" equalTo:self.user];

                    PFPush *push = [[PFPush alloc] init];
                    [push setQuery:pushQuery];

                    NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
                                          [NSString stringWithFormat:@"%@ Wants to be your friend",[PFUser currentUser][@"name"]], @"alert",
                                          @"Increment", @"badge",
                                          @"", @"sound", nil];

                    [push setData:data];
                    [push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

                        if(!error){
                            NSLog(@"Push sent");
                        }else{
                            NSLog(@"%@", error.userInfo);
                        }

                    }];

以下是不工作部分的代码:

PFUser* currentUser = [PFUser currentUser];

    PFQuery *pushQuery = [PFInstallation query];
    [pushQuery whereKey:@"user" equalTo:self.friendsSelected];

    PFPush *push = [[PFPush alloc] init];
    [push setQuery:pushQuery];

    NSString* meetYaMessage = [NSString stringWithFormat:@"%@: MeetYA! @%@ in %@",currentUser[@"name"], self.biz[@"name"], _buttonSelected.currentTitle];

    NSLog(@"MeetYa message: %@ - from_user: %@", meetYaMessage, currentUser.objectId);

    NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
                          meetYaMessage,@"alert",
                          @"Increment", @"badge", @"", @"sound",
                          currentUser.objectId, @"from_user",
                          currentUser[@"name"],@"name",
                          @"meetYa",@"messageType",nil];

    [push setData:data];
    [push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

        if(!error){
            NSLog(@"Push sent");
        }else{
            NSLog(@"%@", error.userInfo);
        }

    }];

我不知道如何追踪这个bug,因为很难知道苹果或解析是否发送了推送通知。

1 个答案:

答案 0 :(得分:0)

在iOS8中,你有一个“不同”的推送注册方法:

<强> iOS8上

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:ni
l]];
[[UIApplication sharedApplication] registerForRemoteNotifications];

iOS7及以下......

[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeNewsstandContentAvailability| UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];