Double gcm notifications

I am testing how to use gcm today. It works fine, but I get double notifications.

What I mean about double notifications is a few minutes after the notification appeared, a second notification with the same contents as the first.

I am testing notification using GCM with PHP (Google Cloud Messaging)

I do not know where I am wrong. I am testing using emulator and real device. This is logcat debugging.

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 
+7
source share
1 answer

Make sure you register BroadcastReceiver once and only once, because it fires every time you register your BroadcastReceiver. You will have problems if, for example, you register it in your onResume method of your Activity , but you do not cancel it in your onPause method.

+1
source

All Articles