0

I have two broadcast receivers and two push services, and i have registered both receivers in the Manifest File.

Receiver 1

    <receiver
        android:name="com.esri.android.geotrigger.MessageReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.esri.android.geotrigger" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_REPLACED" />
            <data
                android:path="com.brillio.beaconservice"
                android:scheme="package" />
        </intent-filter>
    </receiver>

Receiver 2

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

If i comment one receiver and run my application, i am getting push notification properly,

The problem is when both receivers are there is manifest, i am not getting push notification.

John
  • 8,846
  • 8
  • 50
  • 85
  • 1
    What is the purpose of adding 2 receivers? – Pankaj Kumar Aug 25 '14 at 08:28
  • i have two application servers which send two different types of push data – John Aug 25 '14 at 08:48
  • 1
    Then why not you add check on receiver? Two receiver must not work. – Pankaj Kumar Aug 25 '14 at 08:53
  • How to differentiate whether the push is from particular application server ? – John Aug 25 '14 at 11:31
  • 2
    Add a key into json data which will contain the server type value. While parsing do your task depend on that value. – Pankaj Kumar Aug 25 '14 at 11:34
  • possible duplicate of [Getting GCM Error: INVALID\_SENDER occasionally in an app that has two GCM BroadcastReceivers](http://stackoverflow.com/questions/18734335/getting-gcm-error-invalid-sender-occasionally-in-an-app-that-has-two-gcm-broadc) – Eran Aug 25 '14 at 13:12

1 Answers1

1

I have solved it by enabling and disabling receievers dynamically

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

ComponentName receiver = new ComponentName(context, myReceiver.class);
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(receiver,
    PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
    PackageManager.DONT_KILL_APP);
John
  • 8,846
  • 8
  • 50
  • 85