[英]How to disable or turn off notification come from system tray?
大家好,我正在开发一个使用 firebase 云消息传递的应用程序。 在这个应用程序中,我使用的是 BroadcastReceiver 而不是 FirebaseMessagingService。
在这里,BroadcastReceiver 用于在 SQLite 中在前台/后台或应用程序被终止时保存/存储通知数据。
我面临的问题是,应用程序显示两个通知(即一个来自系统托盘,另一个来自应用程序)。 我不希望来自系统托盘的通知。
那么,是否有任何可能的方法来阻止来自系统托盘的通知。
你是如何发送消息的? 如果您在发送之前创建Notification
消息(或混合Notification
和Data
消息),则通知只会出现在系统托盘中。
文档会告诉您哪些类型的消息会进入托盘,哪些类型的消息会被应用程序的接收器捕获,以及一些Notification
与Data
消息的示例。
Notification
消息示例
var message = {
notification: {
title: '$GOOG up 1.43% on the day',
body: '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
},
android: {
ttl: 3600 * 1000,
notification: {
icon: 'stock_ticker_update',
color: '#f45342',
},
}
}
Data
信息示例
var message = {
data: {
title: '$GOOG up 1.43% on the day',
body: '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
},
android: {
ttl: 3600 * 1000,
notification: {
icon: 'stock_ticker_update',
color: '#f45342',
},
}
}
如果您使用云函数发送消息,请查看此参考文档,其中概述了可用于构建消息的所有参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.