我正在嘗試向特定設備發送推送通知,但如果我發送到某個頻道,我只能使其工作。解析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