我尝试了一些示例,使用FCM推送单个用户的通知。它工作正常。现在我正在尝试使用FCM为多个用户发送推送通知。任何推荐网站或代码都会有所帮助。
先谢谢。
我在这里分享我的代码。请看看。
public void onTokenRefresh() {
super.onTokenRefresh();
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
storeRegIdInPref(refreshedToken);
sendRegistrationToServer(refreshedToken);
Intent registrationComplete = new Intent(Config.REGISTRATION_COMPLETE);
registrationComplete.putExtra("token", refreshedToken);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
答案 0 :(得分:0)
您可以在fcm请求中使用registration_ids键:
推送通话格式:
Link:
https://fcm.googleapis.com/fcm/send
Headers:
Authorization:key=<server key>
Content-Type: application/json
Body:
{
"notification":{
"title":"Testing 6",
"body":"PUsh test 6",
"sound":"default",
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
},
"data":{
"Type":"ALBUM",
},
"priority": "high",
"content_available": true,
"registration_ids": ["token 0","token 1","token 2"]
}