I'm testing how to use gcm today. It works ok but I get double notifications.
What I mean about double notifications is few minutes after the notification came, there's second notification with exact same content as the first.
I'm testing the notification using GCM with PHP (Google Cloud Messaging)
I don't know where I'm going wrong.. I'm testing using emulator and a real device This is the logcat debug
02-27 16:05:36.192: V/GCMBroadcastReceiver(513): onReceive: com.google.android.c2dm.intent.RECEIVE
02-27 16:05:36.192: V/GCMBroadcastReceiver(513): GCM IntentService class: mypackage.GCMIntentService
02-27 16:05:36.201: V/GCMBaseIntentService(513): Acquiring wakelock
02-27 16:05:36.221: V/GCMBaseIntentService(513): Intent service name: GCMIntentService-DynamicSenderIds-2
02-27 16:05:36.312: V/GCMBaseIntentService(513): Releasing wakelock
.
.
.
02-27 16:11:14.282: V/GCMBroadcastReceiver(513): onReceive: com.google.android.c2dm.intent.RECEIVE
02-27 16:11:14.282: V/GCMBroadcastReceiver(513): GCM IntentService class: mypackage.GCMIntentService
02-27 16:11:14.291: V/GCMBaseIntentService(513): Acquiring wakelock
02-27 16:11:14.302: V/GCMBaseIntentService(513): Intent service name: GCMIntentService-DynamicSenderIds-3
02-27 16:11:14.402: V/GCMBaseIntentService(513): Releasing wakelock
Verify that you register your BroadcastReceiver once and only once, because it fires for every time that you register your BroadcastReceiver. You will get problems if, for example, you register it in your onResume
method of your Activity
but you do not unregister it in your onPause
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With