1

I am testing the sample project for gcm notification from google https://developers.google.com/cloud-messaging/android/start

This project is using com.google.android.gms:play-services-gcm:9.0.0

After I install the app to my phone via android studio. I kill the app from my phone(not force kill from setting). Then, I tried to send notification message according to google instruction.

Notification cannot show on my phone. When I check the logcat. I found the following log about GCM.

06-08 11:19:37.859 5080-5080/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=gcm.play.android.samples.com.gcmquickstart (has extras) }

After that I launch the app in phone and kill the app again, then send GCM again to my phone. At that time, notification can show correctly in my phone. It seem, application need to restart one time for receiving gcm notification or application should be received notification before user kill the app.

How should I solve this problem? As I know, lower version of play-services-gcm:9.0.0 do not have this kind of problem.

Kyaw Min Thu L
  • 537
  • 8
  • 26

4 Answers4

1

EDIT: It maybe that you gym token doesn't have time to register with the server. Do you get a token and a registration confirmation from the server?

If your just starting with GCM then I would suggest to use FCM it is replacing GCM. https://firebase.google.com/docs/cloud-messaging/

Same thing but with support and new examples. It looks even easier to use than GCM.

MNM
  • 2,673
  • 6
  • 38
  • 73
  • It does, I use it in my older apps, but I am moving to FCM and if you are not building a legacy systems then I would suggests to go to FCM instead of GCM for your own benefit – MNM Jun 08 '16 at 03:48
  • Thanks for knowledge. But i think there is some limitation in FCM because they are provide only 100 connection at a time in free plan. – Arpit Patel Jun 08 '16 at 03:53
  • My current project is using GCM and it need to support start from gingerbread. So, I cannot migrate to FCM currently. Thanks for your suggestion. :) – Kyaw Min Thu L Jun 08 '16 at 04:13
1

It's a feature of the Android platform. Force stopping an application by the user puts the application in a stopped state and none of its code is run, including any broadcast receivers declared in manifest. Only when the user explicitly launches the app it is put in a state where the receivers get fired.

Read this thread

Community
  • 1
  • 1
Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
1

When I installed the app by using apk file, this problem is not happen. This problem is only happen when I install the app by running project in android studio. Thanks for all suggestion and answer.

Kyaw Min Thu L
  • 537
  • 8
  • 26
0

Best fix I have so far is to unplug the phone, kill the app, restart the app then kill it again. Doing this will have the notification displayed even after installing it via android studio. Here is another thread regarding the issue: https://code.google.com/p/android/issues/detail?id=219084

Pellet
  • 2,254
  • 1
  • 28
  • 20