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

Solution 1:

After struggling with a similar issue I managed to get it to work.

I send following json data through postman:

{
  "data": {
    "body": "Test body from curl"
  },
  "registration_ids": ["Token"],
  "webpush": {
    "headers": {
      "Urgency": "high"
    }
  },
  "android": {
    "priority": "high"
  },
  "priority": 10
}

It seems like the last "priority":10 is what's fixing it for me.

I could not find any reference to this in the Firebase documentation, but in the deprecated GCM documentation it's used. https://developers.google.com/cloud-messaging/concept-options

Solution 2:

TL;DR - make sure to set the notification priority correctly based on the JSON payload structure for FCM's legacy HTTP protocol vs its HTTP v1 protocol.

There may already be sufficient answers from posts above based on your circumstance or implementation, but I wanted to provide an answer with more context based on the distinction between the legacy HTTP and HTTP v1 protocols that FCM provides in their documentation, but there is a subtle difference between the two protocol APIs when setting notification priority.

Our team experienced the same problem of not receiving push notifications on Android 6+ devices that have Doze enabled even though our server was seemingly setting the priority correctly in the FCM API payload that similar to the payload provided in the original question. We rely on Amazon SNS to forward payloads to FCM, and the payload sent from our server to Amazon SNS would set the priority based on the AndroidConfig JSON object:

{
    "android": {
        "priority": "high"
    }
}

However, this is only correct according to the HTTP v1 protocol. What we didn't realize is that Amazon SNS is likely still using the legacy HTTP protocol where the priority has to be set at the top-level of the JSON payload:

{
    "priority": "high", // legacy HTTP protocol (this can also be set to 10)
    "android": {
        "priority": "high" // HTTP v1 protocol
    }
}

Thus, the notification priority would only take effect and enable push notifications to be received while in Doze when the legacy HTTP priority parameter was set to "high" or 10.

For context, these are the API endpoints for each protocol when sending messages to FCM:

  • Legacy HTTP: https://fcm.googleapis.com/fcm/send
    • Requires top-level "priority" param (see here)
  • HTTP v1: https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send
    • Requires "android" object with "priority" param (see here)