![](/img/trans.png)
[英]How to handle multiple notification when app in background or killed in FCM services
[英]FCM - When app is killed/in background, app receives notification but does not play the notification sound
我在android中集成了FCM。 一切都运行正常,但当我的应用程序在后台时,它正在接收通知,但它没有播放通知声音。
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification_icon" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/notification_icon_background" />
我在应用程序标记内的Android.manifest中添加了上面的代码。
你能帮我么?
在有效载荷中使用这样的字段。
$fields=array('to'=>fdfdfdfdsfdsdfdfdsfdsfdfdsfd" ,'notification'=>array('title'=>'mytitle','body'=>$title,'click_action'=>'abc','icon'=>'ic_stat_final','sound'=>'default','color'=>'#00aff0'),'data'=>array('ghmid'=>$hgmid,'page'=>$page));
请从服务器传递以下数据:
{
"to" : "deviceToken",
"notification" : {
"body" : "Pass body here",
"title" : "Title For Notification",
"icon" : " icon ",
"sound" : "notification sound here"
}
}
你也可以传入声音部分作为“默认”
我觉得上述所有答案都有帮助,但是如果你需要从使用java开发的服务器端开始,你需要这样做:
JSONArray registration_ids = new JSONArray(Arrays.asList(data));
message.put("registration_ids", registration_ids);
message.put("priority", "high");
JSONObject notification = new JSONObject();
notification.put("title", "Happy Googling");
notification.put("body", "A Sinha");
notification.put("sound","default");
message.put("notification", notification);
post.setEntity(new StringEntity(message.toString(), "UTF-8"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.