I'm not quite sure how to interpret this sentences in the GCM Client documentation:
The android.permission.WAKE_LOCK permission so the application can keep the processor from sleeping when a message is received. Optional—use only if the app wants to keep the device from sleeping.
.
If you don't hold a wake lock while transitioning the work to a service, you are effectively allowing the device to go back to sleep before the work completes. The net result is that the app might not finish processing the GCM message until some arbitrary point in the future, which is not what you want.
and
Using WakefulBroadcastReceiver is not a requirement. If you have a relatively simple app that doesn't require a service, you can intercept the GCM message in a regular BroadcastReceiver and do your processing there.
I'm not quite sure if my app needs to hold a wakelock or not (or if it requires a service). The Push Notification part is quite important to the app and it should not be delayed for more than a few minutes. Is there a chance that the BroadcastReceiver gets suspended before receiving all the data?
GcmReceiver
only started working without the wake lock permission (as mentioned by @RobMeeuwisse) in Google Play Services v8.4.0 (com.google.android.gms:play-services-gcm:8.4.0
). Prior to v8.4.0, a crash occurs when usingGcmReceiver
without the wake lock permission. In v8.4.0 without the wake lock permission, there is a warning: "Missing wake lock permission, service start may be delayed" – user1652110