我正在尝试向特定设备发送推送通知,但如果我发送到某个频道,我只能使其工作。解析iOS:向特定人员/设备发送推送通知
“userQuery.countObjects”正在返回1个用户发现,所以我不知道什么是错,帮助!
这里是我的代码:
PFUser *user1= [friendUsers objectAtIndex:0];
// Associate the device with a user
PFInstallation *installation = [PFInstallation currentInstallation];
installation[@"user"] = [PFUser currentUser];
[installation saveInBackground];
PFQuery *userQuery = [PFUser query];
[userQuery whereKey:@"fbId" equalTo:user1[@"fbId"]];
userQuery.limit = 1;
NSLog(@"cnt=%d", userQuery.countObjects);
// Find devices associated with these users
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"user" matchesQuery:userQuery];
// Send push notification to query
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery]; // Set our Installation query
[push setData:data];
[push sendPushInBackground];
解析推仪表板显示了我这个,我已删除了ID
PUSH ID
dkfo3WhNod
TARGETING
user advanced operator ($inQuery {"className"=>"_User", "limit"=>"1", "where"=>{"fbId"=>"xxxx"}})
SENDING TIME
October 16th, 2015 at 4:37 PM
EXPIRATION
None
FULL TARGET
{
"user": {
"$inQuery": {
"className": "_User",
"limit": "1",
"where": {
"fbId": "xxx"
}
}
}
}
FULL DATA
{
"alert": "Hi",
"badge": "Increment",
"sound": "hi.wav"
}
http://stackoverflow.com/questions/27690215/sending-push-notification-to-all - 用户在查询 –
@NicolasS良好的信息,但不是问题的根源。安装查询,在这种情况下称为'pushQuery',正在设置 – Russell
奇怪的是,这段代码现在工作正常! – cal