1

I am creating an app which has the GCM integration specifically for my app and i am using one third party library which also contains GCM integration. So the problem is i have to add two broadcast receiver in my manifest.xml and both gets called when a notification comes from the server. So i get two notification every time. now i cant change anything into library so is there any way for me to manage that or someone can suggest anything that how can i manage the two GCM receivers.

Note: There are separate services and receivers for both my app and library.

Hardik Chauhan
  • 2,750
  • 15
  • 30
  • Isn't it a bad design? But you can add a flag into message while sending from server, and you can use that flag into application code to know that what to do for which app/lib. – Pankaj Kumar Dec 19 '14 at 05:22
  • It is i know but its necessary for my app to have GCM and library is also had it so cant do anything for that. I have try putting flag but the flag will only check in my app so when a notification comes both receivers will call and i can manage it in my GCMIntentService class using the flag but Library receiver will also gets called and i will get notification and i can't prevent that. – Hardik Chauhan Dec 19 '14 at 05:38
  • So you don't want to receive any message into lib's receiver?? So why don't you disable that receiver? – Pankaj Kumar Dec 19 '14 at 05:43
  • No i want receive the message that comes form the specific receiver means if message sends from App server that show only app notification if it comes from lib server that only that notification shows. So do you have any idea how to manage that or can i put some conditional logic or something? – Hardik Chauhan Dec 19 '14 at 05:57
  • Related question - http://stackoverflow.com/questions/23126646/push-notification-using-jar-is-not-working/ – Eran Dec 19 '14 at 08:39
  • Thanks i've read that solution but the problem is in that solution he had two different sender id for lib and app. In my case the library is using the same sender id of my app. so that wont work for me. – Hardik Chauhan Dec 19 '14 at 09:56

2 Answers2

0

you can enable/disable receivers

http://developer.android.com/training/monitoring-device-state/manifest-receivers.html

urSus
  • 12,492
  • 12
  • 69
  • 89
0

The way I do it is that I put logic in my Receiver class. if it does not have a certain parameter then ignore it and the second receiver will deal with it.

Zuhair Kj
  • 159
  • 2
  • 10