发送 Firebase 通知 (FCM) 时如何唤醒设备

how I can wake up the device when send Firebase notification (FCM)

每当我发送 FCM 时我的手机正在充电,它就会被唤醒

但是当它没有在充电时,直到我按下电源或主页按钮唤醒手机才收到通知

有没有办法让它在不充电的情况下唤醒

我尝试过的事情:

  1. 来自开发者选项(将 Linit 后台进程设置为最多 4 个)
  2. FCM 发送时不包含通知JSON,只包含 数据
  3. 已添加并请求此权限RECEIVE_BOOT_COMPLETED WAKE_LOCK

documentation建议您应该发送高优先级消息来唤醒设备。

FCM attempts to deliver high priority messages immediately, allowing the FCM service to wake a sleeping device when necessary and to run some limited processing (including very limited network access). High priority messages generally should result in user interaction with your app or its notifications.

另请参阅:

  • Firebase message with high priority not waking device from Doze android 6+