使用Parse推送通知接收问题

时间:2013-05-31 12:07:35

标签: iphone ios push-notification apple-push-notifications parse-framework

我正在尝试通过

发送推送通知
PFPush *push = [PFPush push];
[push setQuery:pushQuery];
[push setPushToIOS:YES];
[push setData:data];
[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (!succeeded)
        WMLog(@"Push sending Error: %@", error);
    else
        WMLog(@"Push Sent.");
}];

不知何故,在parse.com上推送通知列表表示订阅者数量已收到推送通知。但有时它在某些设备上没有同时接收某些设备正在接收通知,有时所有设备都接收到所有推送通知。那么可能是为什么有时候通知没有在设备上接收的原因。期待您的回复。

修改 代码是:

    PFQuery *requestFromQuery = [PFQuery queryWithClassName:kMPFRequestsClassKey];
    [requestFromQuery whereKey:kMPFActivityStatusKey equalTo:kMPFFriendStateConnected];
    [requestFromQuery whereKey:kMPFActivityFriendKey equalTo:objC.objUser];

    PFQuery *fromQuery = [PFQuery queryWithClassName:kMPFReflectionsClassKey];
    [fromQuery whereKey:kMPFUsersClassKey matchesKey:kMPFUsersClassKey inQuery:requestFromQuery];

    PFQuery *requestToQuery = [PFQuery queryWithClassName:kMPFRequestsClassKey];
    [requestToQuery whereKey:kMPFActivityStatusKey equalTo:kMPFFriendStateConnected];
    [requestToQuery whereKey:kMPFUsersClassKey equalTo:objC.objUser];

    PFQuery *toQuery = [PFQuery queryWithClassName:kMPFReflectionsClassKey];
    [toQuery whereKey:kMPFUsersClassKey matchesKey:kMPFActivityFriendKey inQuery:requestToQuery];

    PFQuery *reflectionsQuery = [PFQuery orQueryWithSubqueries:[NSArray arrayWithObjects:fromQuery, toQuery, nil]];
    [reflectionsQuery orderByDescending:@"updatedAt"];
    [reflectionsQuery setLimit:1000];

    PFQuery *pushQueryFriends = [PFInstallation query];
    [pushQueryFriends whereKey:kMPFInstallationUserKey matchesKey:kMPFUsersClassKey inQuery:reflectionsQuery];

    PFQuery *pushQueryOwners = [PFInstallation query];
    [pushQueryOwners whereKey:kMPFInstallationUserKey equalTo:objC.objUserReflectionOwner];

    PFQuery *pushQuery = [PFQuery orQueryWithSubqueries:[NSArray arrayWithObjects:pushQueryFriends, pushQueryOwners, nil]];
    [pushQuery whereKey:kMPFInstallationNotificationEnableKey equalTo:[NSNumber numberWithBool:YES]];
    [pushQuery whereKey:kMPFInstallationUserKey notEqualTo:[PFUser currentUser]];

0 个答案:

没有答案