7

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
Community
  • 1
  • 1
user1912180
  • 111
  • 1
  • 6
  • even facebooks push has the same problem for a few days ;) i am experiancing it same notif 2wise so should be a problem with the server -- not cause f ur implimentation dont worry – Athul Harikumar Feb 27 '13 at 09:49
  • So the error is at the google? It's not on my code? I'm implementing it as exactly as the http://developer.android.com/google/gcm/index.html said – user1912180 Feb 27 '13 at 09:57
  • i hope so .. beliving on the senario that facebokks app also gets 2 notif for same msg :) – Athul Harikumar Feb 27 '13 at 10:00
  • We too. We are experiencing the same problem in all our apps since Monday. – Dani C. Feb 27 '13 at 10:25
  • 1
    By the way, as I said, we are in all our customer apps integrated in our platform (MyMalcom) are suffering this duplicates, but we are wondering why software like Whatsapp doesn't have this problem. – Dani C. Feb 27 '13 at 10:54
  • Another related post here: http://stackoverflow.com/questions/15102055/gcm-duplicated-messages/15110473#15110473 – Ferran Maylinch Feb 27 '13 at 11:10
  • Thanks for the comments and link to the related post(it didn't appear when I google search and making this post). It appears that I'm testing the gcm at the bad moment lol. Link to the google group about the problem: https://groups.google.com/forum/#!topic/android-gcm/EHZUTEJMeyw – user1912180 Feb 28 '13 at 03:42
  • are you sure you have not spooked up your app at the configuration end? May be you have registered duplicate apps there? – Nezam Mar 05 '13 at 11:02
  • No, I implemented the gcm test app directly from the google official site. See the comments above as why this happens. Thanks :) – user1912180 Mar 07 '13 at 02:53

1 Answers1

1

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.

Martijn de Milliano
  • 3,572
  • 3
  • 31
  • 43