GCM Message is not sent when the app is not open?

后端 未结 2 1758
闹比i
闹比i 2021-01-28 03:44

Recently I implement the GCM on my app. I followed the tutorial code at this website

http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifi

2条回答
  •  清酒与你
    2021-01-28 04:42

    WhatsApp doesn't rely entirely on GCM (I'm not sure if it relies on GCM at all). If you open your Android device's Settings and go to Applications and then Running services (the menus may be a little different if you are using a different Android version than I'm using, which is 2.3.6), you'll see there's a WhatsApp service running in the background (assuming you have WhatsApp installed). If you stop that service, you would stop receiving messages from WhatsApp until you launch that app again.

    Your app can accept GCM broadcasts only as long as you don't kill it explicitly. Once you kill it, it won't receive any broadcasts until the next time you launch it (according to what I read, that has been the case since Android 3.x). If, however, you move your app to the background (for example by launching another app or hitting the back button until you move to the home screen or to another app), your app would still get messages from GCM.

提交回复
热议问题