Firebase messaging - whats “content_available” : true

最后都变了- 提交于 2020-06-13 05:40:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/50765659/firebase-messaging-whats-content-available-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!