【发布时间】:2016-05-22 19:03:18
【问题描述】:
我根本无法接收推送通知。我的接收器类中的 onPushReceieved 方法永远不会被调用。
这是我的清单的样子:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.compName.appName.permission.C2D_MESSAGE" />
<uses-permission android:name="com.compName.appName.permission.C2D_MESSAGE" />
<application>
.
.
<service android:name="com.parse.PushService" />
<receiver android:name="com.compName.appName.helpers.MyParsePushReciever"
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.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.compName.appName" />
</intent-filter>
</receiver>
</application
这是我的应用程序 onCreate 方法中 Parse 的 init 方法:
Parse.initialize(this, app_id, client_id);
PushService.startServiceIfRequired(this);
ParseInstallation.getCurrentInstallation().saveInBackground();
这是我的 Receiver 类的 onPushReceived 方法:
@Override
protected void onPushReceive(Context context, Intent intent) {
Log.i("hereeeeeeeeee === ", "on push recieve");
}
我永远无法看到该日志。 OnPushReceive 永远不会被调用。有什么我遗漏的吗?
【问题讨论】:
-
检查你的清单我认为包名是错误的。我说的是解析推送的经验。
-
你能说得更具体点吗?谢谢
-
将接收器名称从“com.compName.appName.helpers.MyParsePushReciever”更改为“com.parse.ParsePushBroadcastReceiver”
-
但我使用的是我自己的扩展 ParsePushBroadcastReceiver 的子类。这是否意味着我应该保持接收者名称的原样?
-
它没有。即使有,我的子类如何捕获 OnpushReceived 方法?
标签: java android parse-platform push-notification push