FCM - 当应用程序被杀害/在后台,应用会收到通知,但不播放通知声音
我已经在Android的整合FCM。一切工作正常,但当我的应用程序在后台,它正在接收通知,但它不播放通知声音。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中添加了上述代码。
你能帮帮我吗?
我觉得所有上述答案是有帮助的,但如果你需要从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"));
采用现场像这样的有效载荷。
$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));
为什么减我贴我的工作代码,你可以改变你acording我 –
一样使用它不完全 –
我没有给负点......虽然从您的文章我能得到一个想法,如何去...谢谢! –
请把您的服务器中的数据如下:
{
"to" : "deviceToken",
"notification" : {
"body" : "Pass body here",
"title" : "Title For Notification",
"icon" : " icon ",
"sound" : "notification sound here"
}
}
您也可以传递声音片段为“默认”
你需要使用数据有效载荷,而不是noti fication –
@Divyesh你能请张贴的答案或作为参考的链接? –
搜索通知与数据有效负载Firebase通知。你得到链接 –