Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement multiple GCM push notifications in a single app?

I'm trying to implement two 3rd party libraries (Parse & Localytics) which uses GCM push notifications but I can't seem to get both to work together. It's either one or the other that will work.

<receiver android:name="com.parse.GcmBroadcastReceiver"
          android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
</receiver>



<receiver android:name="com.localytics.android.PushReceiver"
          android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
</receiver>
like image 656
Derrick Avatar asked Apr 01 '15 02:04

Derrick


1 Answers

GCM only is aware of your app, not the content of the GCM payload.

You need a common receiver that can parse the intent received for the particular data that identifies it as Localytics or Parse, then forward that intent to the appropriate receiver for either service.

GCM is based on "app registration" not on "app feature registration" - it will deliver to your app, not a particular receiver within your app.

like image 71
Jim Avatar answered Nov 15 '22 00:11

Jim