(Android)ParsePushBroadcastReceiver的子类在推送通知时不会被调用。 (parse.com)

时间:2015-03-20 11:04:12

标签: android parse-platform

我试图覆盖Android平台上Parse.com的API接收推送通知的默认行为。根据SO上的各种帖子以及Parse的文档 - 我创建了以下类:

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");
    }
}

在我的清单中,我也按如下方式覆盖接收器:

<!-- <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>

收到推送通知后,我的接收器似乎无法被呼叫 - 通知区域中会显示一条通知,单击此按钮会执行默认操作。在Logcat中没有任何地方出现我的调试消息。

我在我的智慧结束时试图弄清楚我最容易忽视的一件非常简单的事情。

非常感谢任何建议或建议,

干杯,

肖恩

1 个答案:

答案 0 :(得分:2)

您还必须注册GCM广播接收器

<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>