Push notifications are delayed in Android Doze mod

2019-06-27 04:07发布

问题:

I am putting my Android device to sleep via adb:

adb shell dumpsys battery unplug
adb shell dumpsys deviceidle step <-- repeat until state is IDLE

Then I am sending the following JSON:

{
   "to":"dYA7tVZrfag:APA91bFVqddVcJHnr_7ZhgNC5iu4Y6XKcLbSVD4DlZgfjMKwKvZhJHiKR4DIzpMrX8zUL15C_adfyEcrlI9q6zOFqFs_zwNPTVIDm-v20ZK0qgagKYGaQE1OPBqdH4P_JHYIXOIS3gfn",
    "priority": "high",
    "data":{
        "test0":"test0",
        "test1":"test1"
    }
}

Result: Nothing... until I wake up the device, then I get all the messages queued. I am monitoring if messages are coming by putting logs in the method onMessageReceived().

I googled around and some people say using an older version of Android Studio or upgrading the version (9.4.0) of the FCM SDK would fix the problem. I've done both with no success.

Edit: This problem seem to only happen with the Samsung Galaxy S5