Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase messaging - whats "content_available" : true

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?

like image 382
Abhishek Mathur Avatar asked Jan 28 '23 23:01

Abhishek Mathur


1 Answers

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.

like image 150
AL. Avatar answered Feb 11 '23 06:02

AL.