当应用程序处于后台时,在 onMessageReceived 中未收到 Firebase 通知
Firebase Notification Not Receive in onMessageReceived when app is in background
我在我的应用程序中使用 FCM
发送通知并且一切正常,但是当我的应用程序在后台时,通知由 android 系统通知托盘处理
我想处理来自我自己的通知我正在发送此有效负载以发送通知
$fields = array(
'notification' => $notification,
'to' => '/topics/updates'
);
这将在我的应用程序处于 forground
时调用我的 onMessageReceived
但是当我的应用程序在后台时这不会调用我的 onMessageReceived
请求由系统本身处理
我想在我的应用处于 background
时调用我的 onMessageReceived
我也在尝试删除 notification key
并且只像这样发送 data key
$fields = array(
'data' => $notification,
'to' => '/topics/updates'
);
但是当我从上面的字段发送请求时 onMessageReceived
在 forground and background
的两种情况下都没有被调用
我正在 xiaomi redmi note 4 (oreo)
、redmi 4x(android 10)
和 android emulator(marshmello)
中尝试这个
我正在按照这个 ans 解决我的问题,但对我不起作用
我的 FCM 版本是 17.3.4
我的 android 工作室版本是 3.5.3
如果未收到数据消息,则有效负载可能有误。这是我的有效载荷示例(.js,但结构应该几乎相同):
const payload = {
data: {
title: finalTitle,
body: message,
icon: icon
},
topic: channel
};
admin.messaging().send(payload)
.then((response) => {
return
})
抱歉 post 这个愚蠢的问题 当我们 post 只有数据密钥而不是通知密钥时,FCM 在后台工作
我的错误是我用这个包裹了我的通知生成器
if (remoteMessage.getNotification() != null) {
// other code
}
我在我的应用程序中使用 FCM
发送通知并且一切正常,但是当我的应用程序在后台时,通知由 android 系统通知托盘处理
我想处理来自我自己的通知我正在发送此有效负载以发送通知
$fields = array(
'notification' => $notification,
'to' => '/topics/updates'
);
这将在我的应用程序处于 forground
时调用我的 onMessageReceived
但是当我的应用程序在后台时这不会调用我的 onMessageReceived
请求由系统本身处理
我想在我的应用处于 background
onMessageReceived
我也在尝试删除 notification key
并且只像这样发送 data key
$fields = array(
'data' => $notification,
'to' => '/topics/updates'
);
但是当我从上面的字段发送请求时 onMessageReceived
在 forground and background
我正在 xiaomi redmi note 4 (oreo)
、redmi 4x(android 10)
和 android emulator(marshmello)
我正在按照这个 ans 解决我的问题,但对我不起作用
我的 FCM 版本是 17.3.4
我的 android 工作室版本是 3.5.3
如果未收到数据消息,则有效负载可能有误。这是我的有效载荷示例(.js,但结构应该几乎相同):
const payload = {
data: {
title: finalTitle,
body: message,
icon: icon
},
topic: channel
};
admin.messaging().send(payload)
.then((response) => {
return
})
抱歉 post 这个愚蠢的问题 当我们 post 只有数据密钥而不是通知密钥时,FCM 在后台工作
我的错误是我用这个包裹了我的通知生成器
if (remoteMessage.getNotification() != null) {
// other code
}