I have a problem related to time_to_live
. I get messages when the device is on, but when it is offline I don't get the message or at least it is not sent in the first 15 minutes. I'm sending the message with delay while idle true and time_to_live
2419200. Any ideas what is happening, maybe I misread the documentation.
问题:
回答1:
From the documentation :
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.
time_to_live : How long (in seconds) the message should be kept on GCM storage if the device is offline. Optional (default time-to-live is 4 weeks, and must be set as a JSON number). If you use this parameter, you must also specify a collapse_key.
You don't need to set the time_to_live value to 2419200. It is the default value.However, if you set it you should also set the collapse_key.
collapse_key : An arbitrary string (such as "Updates Available") that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client. This is intended to avoid sending too many messages to the phone when it comes back online. Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server. See Advanced Topics for more discussion of this topic. Optional, unless you are using the time_to_live parameter—in that case, you must also specify a collapse_key.
For more details check tutorial again.