在com.google.android.gms.gcm.GcmReceiver中收到解析推送消息?

时间:2015-08-19 10:49:03

标签: parse-platform

我使用GCM,我也想将Parse SDK用于没有Google Play服务的设备。

对于gcm实现我在AndroidManifest.xml中声明了这些

<receiver
    android:name="com.google.android.gms.gcm.GcmReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="com.woow.talk" />
    </intent-filter>
</receiver>
<!-- [END gcm_receiver] -->

<!-- [START gcm_listener] -->
<service
    android:name="com.woow.talk.managers.MyGcmListenerService"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
</service>
<!-- [END gcm_listener] -->
<!-- [START instanceId_listener] -->
<service
    android:name="com.woow.talk.managers.MyInstanceIDListenerService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID"/>
    </intent-filter>
</service>
<!-- [END instanceId_listener] -->
<service
    android:name=".managers.MyRegistrationIntentService"
    android:exported="false">
</service>

对于Parse我已经添加了这个:

<receiver android:name="com.woow.talk.managers.MyParsePushBroadcastReceiver" android:exported="false">
    <intent-filter>
        <action android:name="com.parse.push.intent.RECEIVE" />
        <action android:name="com.parse.push.intent.OPEN" />
        <action android:name="com.parse.push.intent.DELETE" />
    </intent-filter>
</receiver>

在应用程序文件中我初始化Parse SDK:

Parse.initialize(this, "xxx", "xxxx");
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
ParseInstallation.getCurrentInstallation().saveInBackground();

从Parse推送但是在GcmReceiver中接收而不是在MyParsePushBroadcastReceiver中。 任何人都能解释一下我做错了什么吗?

谢谢。

编辑:

添加MyParsePushBroadcastReceiver

public class MyParsePushBroadcastReceiver extends ParsePushBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);
    }

    @Override
    protected void onPushReceive(Context context, Intent intent) {
        super.onPushReceive(context, intent);
    }

    @Override
    protected Notification getNotification(Context context, Intent intent) {
        return super.getNotification(context, intent);
    }
}

我也做了一些调试,来自parse的意图来自com.google.android.c2dm.intent.RECEIVE动作,这就是com.google.android.gms.gcm.GcmReceiver捕获的原因。

这可能吗?

1 个答案:

答案 0 :(得分:0)

你可以分享你的MyParsePushBroadCastReceiver类代码,也许你错过了onReceive方法吗