How long will the device stay awake when it receives a FCM high priority message?

梦想与她 提交于 2019-12-08 01:01:33

问题


I read in the Firebase docs that a device will be brought out of sleep if it receives a high priority message from FCM and that the network connection will be opened towards the app server. I have tested this behaviour and i know that it does wake a device from doze.

My use case is such that i need to download an image using a set key in the data tag of the push message. There will be multiple such push notifications and i will be saving all these messages in a db.

After say ten minutes, the notifications will actually be triggered onto the user's screen in order to avoid the multitude of other notifications user has received on immediately turning on the network connection.

My question essentially is:

  1. Will the device be awake long enough for me to download the image and save it to the db (image size is max 100kb)?

  2. Or should I instead defer the downloads to a later time using JobScheduler API in order to ensure network connectivity?


回答1:


Yes, you should defer the downloads but that depends on the nature of your app. Docs say that high priority messages give the app temporary access and as such it is not guaranteed that your image download will actually finish in that window.

Are your app message time sensitive (i mean would the world crumble if the user sees them after 10 minutes)? If not then you should exactly follow your own suggestion. Else may be you can start a foreground service which might prevent the device for being going to doze mode (Be aware your app might drain a lot of battery and eventually this might create a negative impression on the user).



来源:https://stackoverflow.com/questions/42272509/how-long-will-the-device-stay-awake-when-it-receives-a-fcm-high-priority-message

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