簡體   English   中英

使用無法在Android上運行的Facebook ID向特定用戶發送解析推送通知

[英]Sending Parse push notifications to specific users using Facebook ID not working from Android

我正在嘗試將推送通知發送到我的Facebook好友列表中。 我已經為每個Parse用戶存儲了Facebook ID,並且還將該用戶保存在Parse安裝中。 Android實施存在問題,因為當從Android設備發送通知時,通知不會發送給所有朋友,但是當從iOS設備發送通知時,所有朋友都會收到通知。 以下是我從iOS和Android發送通知的代碼。

Android推送的Targeting字段如下:

用戶高級運算符($ inQuery {“where”=> {“fbid”=> {“$ in”=> [“id1”,“id2”,“id3”,“id4”]}},“className”=> “_User”})deviceType是“ios”,“android”,“winphone”或“js”中的任何一個

從iOS推送的Targeting字段如下:

用戶高級運算符($ inQuery {“className”=>“_ User”,“where”=> {“fbid”=> {“$ in”=> [“id1”,“id2”,“id3”,“id4” ]}}}}}} deviceType是“ios”,“android”,“winphone”或“js”中的任何一個

然而,在Android的情況下(基於推送通知中的“訂戶”字段),通知僅發送給1個用戶而不是4個用戶。 在iOS的情況下,其ID在列表中的所有朋友都會收到通知。

任何幫助,將不勝感激。

iOS代碼:

NSMutableArray *friendsArray;
PFQuery *friendQuery = [PFUser query];
[friendQuery whereKey:[NSString stringWithUTF8String:@"fbID"] containedIn:friendsArray];

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

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

[push setMessage:[NSString stringWithFormat:@"%@ sent you this test message!", [NSString stringWithCString:"TestUser" encoding:NSUTF8StringEncoding]]];
[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (!error) {
        NSLog(@"Push sent to users successfully");
    }
    else {
        NSLog(@"Error while fetching sending push from Parse: %@ %@", error, [error userInfo]);
    }
}];

Android代碼:

List<String> friends;
ParseQuery<ParseUser> friendQuery = ParseUser.getQuery();
friendQuery.whereContainedIn("fbID", friends);

ParseQuery<ParseInstallation> query = ParseInstallation.getQuery();
query.whereMatchesQuery("user", friendQuery);

ParsePush push = new ParsePush();
push.setQuery(query);
push.setMessage(userFullName + " sent you this test message from Android!");
push.sendInBackground();

編輯:

我發現了這個問題。 由於ParseInstallation查詢,我得到此異常。

com.parse.ParseException:不允許客戶端對安裝集合執行查找操作。

我該如何解決?

使用ClientKey的應用程序不允許查詢Installation類。

我建議使用獨特的渠道,使用可以針對特定用戶定位推送消息的渠道。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM