android - 如何配置 Firebase 推送通知消息
问题描述
我找到了各种关于如何为 Android 和 ios 的 firebase 上的推送通知配置消息 json 的示例。但我有一个问题,并非所有推送消息都到达我的客户端应用程序。我注意到在不同的 android 版本上它以不同的方式工作。其中一些,没有收到任何消息,其中一些没有配置的铃声,其中一些只有默认铃声,有些工作正常。在客户端,我认为一切都应该没问题。我正在为此使用 xamarin 表单。我的消息 json 看起来像这样。我现在已经读到我应该删除通知标签,但它适用于较旧的机器人?
{
"to": "/topics/MYTOPIC",
"notification": {
"title": null,
"body": "test",
"sound": "de900",
"content_available": true
},
"priority": "high",
"data": {
"missionGuid": "",
"eventGuid": "",
"messageGuid": "e3ab4c34-125b-4ea7-abf7-3ee8fe1453ce",
"ric": "199900",
"title": null,
"body": "test",
"priority": "high",
"sound": "de900"
},
"android": {
"priority": "high",
"notification": {
"title": null,
"body": "test",
"sound": "de900",
"content_available": true
},
"data": {
"missionGuid": "",
"eventGuid": "",
"messageGuid": "e3ab4c34-125b-4ea7-abf7-3ee8fe1453ce",
"ric": "199900",
"title": null,
"body": "test",
"priority": "high",
"sound": "de900"
},
},
"apns": {
"headers": {
"apns-priority": 10
},
"payload": {
"aps": {
"alert": {
"title": null,
"body": "test"
},
"sound": "de900"
}
}
}
}
解决方案
据我所知,设置"priority": "high"
是确保通知立即发送的唯一方法。如果他们仍然无法收到任何东西,那可能是客户端的问题。
对于铃声,据说"sound": "WHATEVER"
应该指定声音,但同样,由于不同的 OEM 和系统变化,发送数据消息并在收到时自己推送通知可能会更一致,但你应该知道即使这样也不能保证送达或铃声。
在某些设备上这工作正常(希望是大多数设备)这一事实表明您可能对配置进行了正确设置,您能做的最好的事情就是自己处理通知,并且可能对特定设备有特殊情况。
推荐阅读
- javascript - React Grid列未在列中显示组件
- ios - 将 Picker 值存储到 UserDefaults
- spring - 使用 Mockito 测试 DefaultUserDtoServiceTest 时,服务不想保存。但是在测试时它抛出了 api - 它可以工作
- c# - WPF中的空“页面”
- python - 是否有一种 R 方法可以从 Python 中的函数中检索多个变量?
- reactjs - 上传图片的输入类型不适用于material-ui对话框,如何解决?
- python - 为什么 os.startfile 没有打开请求的文件
- ios - 按升序删除tableView行时删除不正确的tableView行(从下到上)
- python - 将元素列表映射到另一个列表中的元素范围以创建唯一矩阵
- reactjs - ChartJs 功能组件即使在 forceUpdate 时也不刷新