Firebase messaging - whats "content_available" : true

10,336

If you checked the official documentation first, you'd see the corresponding description:

content_available - On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported.

The title of your post is only asking about content_available, but just to cover the other two, priority (also from the docs):

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.

delay_while_idle has long since been deprecated so I wouldn't bother providing it's behavior.

Share:
10,336
Admin
Author by

Admin

Updated on June 13, 2022

Comments

  • Admin
    Admin about 2 years

    I saw many examples of firebase push like

    { 
      "to" : "egu9jGiMcew:APA91bFv2Rewdz.....KZZmEURvbq-aA2", 
      "data": { 
        "id": 19, 
        "title": "Title test", 
        "msg": "Text of the test", 
        "code": 2, 
        "infosUrl": "ttp://www.secondguide.tours", 
        "longitude": 5.5, 
        "latitude": 44.5, 
        "eventLocation": "nowhere", 
        "startDate": "24/07/2016", 
        "endDate": "25/07/2016", 
      }, 
      "delay_while_idle" : false, 
      "priority" : "high", 
      "content_available" : true 
    } 
    

    I did not get the purpose of

    "delay_while_idle" : false,    
    "priority" : "high",   
    "content_available" : true
    

    in this, can somebody explain?

  • sznrbrt
    sznrbrt almost 3 years
    this answer is golden, just helped to debug a production issue. worth to note that only "high" priority notification through the FCM services work in Doze and App Standby idle modes. if your device is in idle mode it's notifications are delayed until later time.