Firebase iOS notifications not received on device

Viewed 1049

We have two kind of firebase notifications, one with the notification field and one without (this field it's used by the system to display the banner).

The one with is always received, the one without is received for a certain row of attempts and then stops being received.

These are the payloads:

The one always being received:

{
  "content_available": true,
  "data": {
    "pushCategory": "ALEXA",
    "body": "body",
    "message": "message",
    "title": "status/update",
    "updateStatus": {
      "operationId": "7fc0e1ff-cc0d-4045-8b30-69710bf80c24",
      "status": 0,
      "action": "makecoffee",
      "description": "",
      "stock": {
        "remaining": "91",
        "threshold": "10",
        "depletion": false
      }
    }
  },
  "notification": {
    "title": "title",
    "body": "body msg"
  },
  "apns": {
       "headers": {
         "apns-priority": "10"
       }
    },
  "to": "----"
}

The one not being received randomly:

{
  "content_available": true,
  "data": {
    "pushCategory": "ALEXA",
    "body": "body",
    "message": "message",
    "title": "status/update",
    "updateStatus": {
      "operationId": "7fc0e1ff-cc0d-4045-8b30-69710bf80c24",
      "status": 0,
      "action": "makecoffee",
      "description": "",
      "stock": {
        "remaining": "91",
        "threshold": "10",
        "depletion": false
      }
    }
  },
  "apns": {
       "headers": {
         "apns-priority": "10"
       }
    },
  "to": "----"
}

The equivalent notification using directly the APNS servers and without the alert field is always received. (the alert field is the one that tells the system to display the banner)

I contacted the Firebase support but the issue in ongoing, do you know what could be the issue?

1 Answers

I've never used Firebase. I'm not sure if apns-priority in your payload has an effect. I just don't know:

  "apns": {
       "headers": {
         "apns-priority": "10"
       }
    },

I think you have to get rid of it and just use priority field itself. Let Firebase map the fields itself...

From Firebase docs, look for the description of the priority parameter and how it behaves differently for data vs notification :

Sets the priority of the message. Valid values are "normal" and "high." On iOS, these correspond to APNs priorities 5 and 10.

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.

When a message is sent with high priority, it is sent immediately, and the app can display a notification.

The payload with data ends up ultimately with a firebase priority of "normal" which translates to apns-priority 5

For notification the firebase priority of "high" translates to apns-priority of 10

For more on apns-priority, see apns-docs

The priority of the notification. If you omit this header, APNs sets the notification priority to 10.

Specify 10 to send the notification immediately.

Specify 5 to send the notification based on power considerations on the user’s device.

Related