Reputation: 3293
Sometimes when I receive a normal-priority GCM message in my Android app the network doesn't seem to be available. Do normal-priority GCM messages automatically grant an app temporary exemptions to Android M's new Doze and App Standby sleep conditions (namely restricting network access)?
Full Context: I've implemented an App prior to Android-M's release that uses a GCM messaging to tickle installed app instances to download updates on-demand. This is a best practice over polling for updates.
Android-M introduces Doze and AppStandby which seem able to restrict network access when apps aren't using the the new high-priority message type.
Should I switch these tickle messages to high-priority or will I have network access when I receive normal-priority messages? My testing with Android M Previews seems to indicate the network sometimes isn't available.
Upvotes: 1
Views: 466
Reputation: 3293
Network access MIGHT be available and you should not switch your message type to high-priority just to ensure network access is available. You should only switch your message type if the GCM Message is of urgent need to a user on that device. A general rule would be that the notification would fall under the HIGH category when considering the guidance around creating notifications. If you currently use the same GCM messages for periodic sync requests as well as urgent messages you should separate them.
A little more detail on the "Network access MIGHT be available":
As of October 1st up-to-date versions of Google Play services correlate the delivery of GCM normal-priority messages with Doze's maintenance mode, so the network typically won't be restricted. A developer asking this question should consider that a robust app will typically deal with Doze and real-world network connectivity problems at the same time. The app would typically:
The network scheduling routines:
Note: When testing with a device, including one with Android M Preview, make sure Google Play services is fully up-to-date before testing (v8.1+). This typically requires opening the Google Play store app and accepting the Terms of Service.
Upvotes: 1