android推送通知与解析doesen工作

时间:2015-06-26 20:16:35

标签: android parse-platform push-notification

我从parse.com下载了blanck Android Project,然后转到parse.com创建应用程序以获取应用程序&客户端ID KEY,把它放在ParseApplication类上,运行应用程序它在我的设备上工作正常但是当我尝试发送推送通知时我得到它的消息....没有注册设备

那么,怎么了?

有什么想法吗?

public class ParseApplication extends Application {

@Override
public void onCreate() {
super.onCreate();

// Initialize Crash Reporting.
ParseCrashReporting.enable(this);

// Enable Local Datastore.
Parse.enableLocalDatastore(this);

// Add your initialization code here
Parse.initialize(this,"EVIZ5DUourBOfSWykYZIhy4HFgDC0W","HCmjXHOz3SbHnHLlyQVD4uqOnmXdzAy");
ParsePush.subscribeInBackground("", new SaveCallback() {

    @Override
    public void done(com.parse.ParseException e) {
        // TODO Auto-generated method stub
        if (e== null){
            //log.e;
        } else{
            //log.e;
        }

    }
}); 
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// Optionally enable public read access.
// defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
  }
  }

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.miscore"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />
<!-- Internet permission -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!--
   NUEVO
-->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<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.example.miscore.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.miscore.permission.C2D_MESSAGE" />


<application
    android:name="com.example.database.BDApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".SplashScreen"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Inicio"
        android:label="@string/inicio"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Configuracion"
        android:label="@string/title_config"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".TablaGeneral"
        android:label="@string/title_activity_tabla_general"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name=".Calendario"
        android:label="@string/title_activity_calendario"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name=".TablaGoleo"
        android:label="@string/title_activity_tabla_goleo"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name=".About"
        android:label="@string/title_activity_about"
        android:screenOrientation="portrait"
        android:theme="@style/TransparentTheme" >
    </activity>
    <activity
        android:name=".CondUso"
        android:label="@string/title_activity_cond_uso" >
    </activity>
    <activity
        android:name=".AvisoPriv"
        android:label="@string/title_activity_aviso_priv" >
    </activity>
    <activity
        android:name=".FirmaLega"
        android:label="@string/title_activity_firma_legal" >
    </activity>
    <!--
           NUEVO
    -->
    <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.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.tutorials.pushnotifications" to match your app's package name.
        -->
        <category android:name="com.example.miscore" />
      </intent-filter>
    </receiver>
    <receiver android:name="com.parse.ParsePushBroadcastReceiver" 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>
</application>

1 个答案:

答案 0 :(得分:2)

这可能听起来很愚蠢,但请尝试从您的设备卸载您的应用,然后重新安装。 再次尝试使用您的代码,如果没有帮助,请尝试这样做:

file_name

然后,再次卸载并重新安装。