昨天谷歌在Google I/O上展示了基于新Firebase的新通知系统.我在Github上尝试了这个新的FCM(Firebase云消息传递)示例.
尽管我已声明了特定的drawable,但通知的图标始终是ic_launcher
为什么?以下是处理邮件的官方代码
public class AppFirebaseMessagingService extends FirebaseMessagingService {
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should …Run Code Online (Sandbox Code Playgroud) android push-notification googleio firebase firebase-cloud-messaging
根据这句话,我发现:
- registration_ids - 类型字符串数组 - (可选)[消息的接收者]多个注册令牌,最小值1最大1000.
这是我可以发送单个消息的设备令牌的实际限制吗?对主题的消息是否具有相同的限制?
例如:
{
"to": [reg_token_01, reg_token_02, ..., reg_token_1000],
"priority": "high",
"data": {
"title": "Hi Peeps!",
"message": "This is a special message for only for you... More details are available..."
}
}
Run Code Online (Sandbox Code Playgroud)
一如既往,感谢信息和方向!
我可以从Firebase控制台向单个设备,主题和用户细分发送通知.
我想将推送通知发送到用户段.我搜索了很多,但我只是通过脚本向单个用户或主题发送通知而不是用户段.
我尝试了下面的代码
var client = new RestClient("https://fcm.googleapis.com/fcm/send");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "key=mykey");
request.AddParameter("application/json", "\n\n{\"to\" : \"user-segment-name\",\n\"notification\" : {\n \"body\" : \"test message\",\n \"title\" : \"Portugal vs. Denmark\"\n },\n \"priority\":\"high\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Response.Write(response.Content);
Run Code Online (Sandbox Code Playgroud)
我收到的答复如下
{"multicast_id":5837227475989925972,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
Run Code Online (Sandbox Code Playgroud) 在一个应用程序中对Firebase云消息传递的不同主题数量有任何限制吗?