我想在应用程序处于前台时显示通知,并且它只接收 FCM WhatsApp 和其他应用程序显示。在后台,我在通知栏上收到通知,但在用户使用应用程序时收到通知时没有任何反应。我从顶部看起来有点像默认的安卓小弹出窗口。我使用以下正文发送 FCM。
{
"to": "/topics/chatProperty_P00025_14",
"notification" : {
"body" : "great match!",
"content_available" : true,
"priority" : "high",
"title" : "Portugal vs. Denmark",
"sound":"default",
"vibrate":true
},
"data" : {
"body" : "14_P00025",
"content_available" : true,
"priority" : "high",
"title" : "Portugal vs. Denmark",
"type" : "propertyChat",
"sound":"default",
"vibrate":true
}
}
请参阅以下示例代码:
let message = {
to: "fcm_device_token",
data: {
custom_notification: {
body: "Your message",
custom_data: "Any custom data you want to send",
sound: 'default',
priority: "high",
show_in_foreground: true
}
}
}