问题
If an Android device is in standby mode, in which the screen is off, can Google Cloud Messaging send a message to that device? Or does GCM have to wait until the device comes out of standby mode in order to receive messages?
In the docs it states:
Google enqueues and stores the message in case the device is offline. When the device is online, Google sends the message to the device.
There is no indication however what is meant by offline or online. Is a device still online even though its screen is off?
回答1:
Yes mobile Can receive messages in standby Mode unless and until it is connect to internet.
In their Documents online
means connected to internet
and offline
means not connected to internet
.
回答2:
You can control whether a message will be sent to a device which is in standby mode using the delay_while_idle
flag. If you don't include this flag in your message, it's default value is false, and the message will be sent immediately. Of course, whether that message will wake the device or not depends on how your code handles the notifications and whether your app has a WAKE_LOCK
permission.
delay_while_idle
If included, indicates that the message should not be sent immediately if the device is idle. The server will wait for the device to become active, and then only the last message for each collapse_key value will be sent. Optional. The default value is false, and must be a JSON boolean.
来源:https://stackoverflow.com/questions/16850227/does-google-cloud-messaging-send-messages-to-devices-that-are-in-standby-mode