【发布时间】:2019-02-07 19:14:27
【问题描述】:
我从 node.js 服务器发送这样的推送通知:
const message = {
android: {
ttl: 3600 * 1000,
notification: {
icon: 'stock_ticker_update',
color: '#f45342',
sound: "notify"
}
},
token: user.deviceToken,
...notification
};
return await adminCli.messaging().send(message);
对于一些推送消息,我希望它只在前台接收,而不是在应用程序在后台运行时接收...... 因此,对于我在后台收到的特定消息,我想忽略它...是否可以实现?
【问题讨论】:
-
尝试使用 firebase
in-app-messaging功能。它目前处于测试阶段。 firebase.google.com/products/in-app-messaging -
听起来好像是可以从客户端完成的。我认为从服务器端控制是不可能的。
-
在客户端怎么可能做?
-
您可以在收到通知时保存通知数据(例如在 SharedPreferences 中),当应用返回前台时检查是否有通知数据并发布。
标签: android node.js firebase push-notification firebase-cloud-messaging