Sean Leach
Sean Leach

Reputation: 70

(Android) Subclass of ParsePushBroadcastReceiver doesn't get called on push notification. (parse.com)

I'm attempting to override the default behaviour of the receipt of push notifications from Parse.com's API on the android platform. As per various posts on SO, and in Parse's documentation - I've created the following class:

public class HHPBroadcastReceiver extends ParsePushBroadcastReceiver {

    protected void onPushReceive(Context context,
        Intent intent){
        Log.d("DMM", "onPushReceive");
    }

    protected void onPushOpen(Context context, Intent intent) {
        Log.d("DMM", "onPushOpen");
    }
}

In my manifest, I'm also overriding the receiver as follows:

<!-- <receiver
        android:name="com.parse.ParseBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver> -->

    <receiver
        android:name="com.dreamr.hothalls.HHPBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>

Upon receipt of a push notification, my Receiver doesn't seem to get called - A notification appears in the notification area and clicking this carries out the default action. Nowhere in Logcat does my debug message appear.

I'm at my wit's end trying to work out what is most likely something incredibly simple I've overlooked.

Any advice or suggestions would be much appreciated,

Cheers,

Sean

Upvotes: 2

Views: 408

Answers (1)

Irfan Raza
Irfan Raza

Reputation: 2953

You must register GCM broadcast receiver as well

<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="us.anyadir.admissiontable" />
        </intent-filter>
    </receiver>

Upvotes: 2

Related Questions