android Oreo 电池电量不足时未收到 FCM 通知
FCM notifications are not received in android Oreo when battery is low
我目前正在针对 FCM 消息接收事件启动我的视频通话应用程序。它工作正常。但是在 Oreo 中,当 电池电量非常低时 我没有收到任何 FCM 通知。但 Whatsapp 即使在那种情况下也能正常工作
我要发送以下内容JSON:
{
"to" : "XXXDecviceToken",
"data" : {
"callId" : "Call ID",
"displayName" : "Abhilash",
"room" : "2000"
},
"time_to_live" : 0
}
正在查看您的 JSON 请求:
{
"to" : "XXXDecviceToken",
"data" : {
"callId" : "Call ID",
"displayName" : "Abhilash",
"room" : "2000"
},
"time_to_live" : 0
}
有两个问题会导致电池电量不足时无法发送通知:
- 您没有指定优先级,因此数据消息的默认优先级是 "normal":
By default, notification messages are sent with high priority, and data messages are sent with normal priority. Normal priority optimizes the client app's battery consumption and should be used unless immediate delivery is required. For messages with normal priority, the app may receive the message with unspecified delay.
- 您将 "time_to_live" 指定为 0,这意味着如果 FCM 无法立即传递消息,则永远不会传递它(因为它不保存在 FCM 存储中)。
因此,将 "normal" 优先级与 "time_to_live" 0 相结合可能会阻止在电池电量不足时发送消息。
要尝试解决此问题,您可以将优先级设置为 "high":
{
"to" : "XXXDecviceToken",
"data" : {
"callId" : "Call ID",
"displayName" : "Abhilash",
"room" : "2000"
},
"time_to_live" : 0,
"priority" : "high"
}
或将 "time_to_live" 更改为正值(至少有足够的时间让消息有机会在电池重新充电后发送)。
我目前正在针对 FCM 消息接收事件启动我的视频通话应用程序。它工作正常。但是在 Oreo 中,当 电池电量非常低时 我没有收到任何 FCM 通知。但 Whatsapp 即使在那种情况下也能正常工作
我要发送以下内容JSON:
{
"to" : "XXXDecviceToken",
"data" : {
"callId" : "Call ID",
"displayName" : "Abhilash",
"room" : "2000"
},
"time_to_live" : 0
}
正在查看您的 JSON 请求:
{
"to" : "XXXDecviceToken",
"data" : {
"callId" : "Call ID",
"displayName" : "Abhilash",
"room" : "2000"
},
"time_to_live" : 0
}
有两个问题会导致电池电量不足时无法发送通知:
- 您没有指定优先级,因此数据消息的默认优先级是 "normal":
By default, notification messages are sent with high priority, and data messages are sent with normal priority. Normal priority optimizes the client app's battery consumption and should be used unless immediate delivery is required. For messages with normal priority, the app may receive the message with unspecified delay.
- 您将 "time_to_live" 指定为 0,这意味着如果 FCM 无法立即传递消息,则永远不会传递它(因为它不保存在 FCM 存储中)。
因此,将 "normal" 优先级与 "time_to_live" 0 相结合可能会阻止在电池电量不足时发送消息。
要尝试解决此问题,您可以将优先级设置为 "high":
{
"to" : "XXXDecviceToken",
"data" : {
"callId" : "Call ID",
"displayName" : "Abhilash",
"room" : "2000"
},
"time_to_live" : 0,
"priority" : "high"
}
或将 "time_to_live" 更改为正值(至少有足够的时间让消息有机会在电池重新充电后发送)。