我可以在parse.com上的表格中看到我的推送通知。但我的所有设备都无法接收任何通知。 清单
的权限<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.james.fappsilya.fappsapp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.james.fappsilya.fappsapp.permission.C2D_MESSAGE" />
接收者和服务
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.RECEIVE_BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.james.fappsilya.fappsapp.Receiver"
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" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="com.james.fappsilya.fappsapp" />
</intent-filter>
</receiver>
MyApplication
package com.james.fappsilya.fappsapp;
@Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "my code", "my code");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("global", new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
} else {
Log.e("com.parse.push", "failed to subscribe for push", e);
}
}
});
}
和接收者
package com.james.fappsilya.fappsapp;
import android.content.Context;
import android.content.Intent;
import com.james.fappsilya.fappsapp.Activity.MainActivity;
import com.parse.ParsePushBroadcastReceiver;
/**
* Created by fappsilya on 01.04.15.
*/
public class Receiver extends ParsePushBroadcastReceiver {
@Override
public void onPushOpen(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
答案 0 :(得分:0)
尝试通过移动网络使用Parse Push,这解决了我的错误,因为我的大学Wi-Fi由于某种原因阻止了它。