android - Android FCM 通知第一次无法在后台工作
问题描述
Fcm Notification - onMessageReceived 在第一次安装应用程序时未在免费中调用。下次我打开和关闭应用程序时,它开始在后台工作。我在 Redmi k20 pro android 10 版本中进行测试。
有什么建议么
FCM 有效载荷:
{
"to":"dmYZxw7MkC9y58NIK86dp1xypDkCQKBmikujvVtAFJC....",
"priority":"high",
"data":{
"NotifyId":"12",
"title":"777",
"body":"1234456756778787878"
},
"notification":{
"NotifyId":"12",
"title":"777",
"body":"1234456756778787878"
}
}
收到消息时:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
RemoteMessage.Notification notification = remoteMessage.getNotification();
Map<String, String> data = remoteMessage.getData();
Log.d("FROM", remoteMessage.getFrom());
sendNotification(notification, data);
}
解决方案
推荐阅读
- python - 如何找到以大写字母开头的任何单词包围的特定预定义单词?
- java - 如何优化java中的两个for循环
- python - 语音合成模型创建音频但 html 页面返回以前的音频
- android - 从连接到TextureView的视频流中接收所有帧而不会在Android中丢帧
- javascript - 尝试通过 arg 的 ID 发送直接消息时“无法读取未定义的属性‘发送’”
- angular - 如何在 Microsoft Teams 选项卡中检查用户是否为管理员
- ssis - 错误处理中的 SSIS 优先约束最大计数变量
- python - 如何在 discord.py 和烧瓶网站中异步调用而不等待 - python
- reactjs - 除非我也使用 useState,否则为什么不使用 useParams 更改键?
- python - 我无法在 Python 中使用外汇将货币转换转换为整数以去除小数除法