我的代码如下
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.aaa"
android:versionCode="2027"
android:versionName="5.1.5" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<uses-permission
android:name="android.permission.GET_TASKS"
android:protectionLevel="normal" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_OWNER_DATA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<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:name="com.aaa.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.aaa.permission.C2D_MESSAGE" />
<application
android:name="com.aaa.application.SalesEnablementApplication"
android:allowBackup="true"
android:icon="@drawable/ic_app_icon_new"
android:label="@string/app_name"
tools:replace="android:label"
android:largeHeap="true"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="@string/application_id_stage" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="@string/client_key_stage" />
<receiver
android:name="com.xxx.util.NetworkStateReceiver"
android:enabled="false"
android:label="NetworkStateReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
.
.
.
<receiver android:name="com.aaa.pushNotification.PushBroadcastReceiver" >
<intent-filter>
<action android:name="com.aaa.Notification_ACTION" />
</intent-filter>
<!-- <category android:name="android.intent.category.DEFAULT" /> -->
</receiver>
<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.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.aaa.receiver.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>
<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.aaa" />
</intent-filter>
</receiver>
<receiver
android:name="com.aaa.receiver.MyReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.starter.UPDATE_STATUS" />
<action android:name="com.aaa.UPDATE_STATUS" />
<!--
<action android:name="com.push.intent.RECEIVE" />
<action android:name="com.push.intent.DELETE" />
<action android:name="com.push.intent.OPEN" />
-->
</intent-filter>
</receiver>
<!--
<receiver
android:name="com.aaa.receiver.MyReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.aaa" />
</intent-filter>
</receiver>
-->
</application>
</manifest>
我的申请类:
public void onCreate() {
super.onCreate();
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
// Init Parse App after checking the current environment
Parse.initialize(this);
/*if(Environment.ENV.equalsIgnoreCase(Environment.ENV_STAGE)){
Parse.initialize(this, getResources().getString(R.string.application_id_stage), getResources().getString(R.string.client_key_stage));
}else{
Parse.initialize(this, getResources().getString(R.string.application_id_prod), getResources().getString(R.string.client_key_prod));
}*/
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
defaultACL.setPublicWriteAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
// used to store temp objects
dataStore = new DataStore();
eventCaptureHandler = new EventCaptureHandler(this);
}
我使用的是解析SDK版本1.13.0。 在Android 6.0.1(Sony Xperia Z2)上进行测试。
我尝试从Parse Dashboard发送推送消息。我没有收到发送的通知。我注意到Installation表中的DeviceType和pushType设置为(Undefined)。