如何检测点击解析通知?

时间:2015-02-25 19:50:01

标签: android notifications

我在我的应用中使用解析推送通知。 当我向仪表板中的所有设备发送消息时,在使用点击通知时我无法获得发送推送。 有没有办法检测它?

1 个答案:

答案 0 :(得分:1)

当发送和接收推送时,ParsePushBroadcastReceiver调用正确的方法。你应该编写自己的自定义类来覆盖原始的ParsePushBroadcastReceiver。

public class CustomParsePushBroadcastReceiver extends ParsePushBroadcastReceiver {
@Override
protected void onPushOpen(Context context, Intent intent) {
    super.onPushOpen(context, intent);
    //Called when the push notification is opened by the user.
    Log.wtf(TAG, "Opened!");

...如果需要,实施其他方法

具体来说,当用户点击通知时,将调用onPushOpen。​​

另外,请不要忘记更新自定义类的清单

<receiver android:name=".CustomParsePushBroadcastReceiver" 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>

并确保您已调用ParsePush.subscribeInBackground(""),其中参数是您要订阅的频道(将其留空订阅我认为的所有频道)。