无法接收来自 parse.com 的推送通知

Cannot receive push notification from parse.com

我已经实现了 parse.com 在他们的教程中的内容,当我从解析仪表板发送推送时,它显示成功但发送的推送次数为 0。但是每当我想发送推送时它都会显示接收方1 这意味着它可以识别我的设备。我按照 link 中的说明进行了操作,但它不起作用: I can't receive push notifications in app from Parse 我很困惑为什么我在这里没有收到任何通知是我的应用程序 class 代码:

    Parse.initialize(this, "xxxxx", "xxxxx");
    ParseInstallation.getCurrentInstallation().saveInBackground();
    Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
    ParsePush.subscribeInBackground("", 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);
            }
        }
    });

这是我的明确许可:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<permission android:name="com.myapp.main.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.main.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.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" />
            <category android:name="com.myapp.main" />
        </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>
    <!-- replace @drawable/push_icon with your push icon identifier -->
    <meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/applogo"/>

编辑:这是日志:

02-25 13:52:53.681    4636-4653/com.myapp.main E/com.parse.ManifestInfo﹕ Cannot use GCM for push because the app manifest is missing some required declarations. Please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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:name="com.myapp.main.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.main.permission.C2D_MESSAGE" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<service android:name="com.parse.PushService" />
<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.myapp.main" />
</intent-filter>
</receiver>

02-25 13:57:13.004    5598-5598/com.myapp.main E/com.parse.PushService﹕ Tried to use push, but this app is not configured for push due to: Push is not configured for this app because the app manifest is missing required declarations. Please add the following declarations to your app manifest to support either GCM or PPNS for push (or both). To enable GCM support, please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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:name="com.myapp.main.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.main.permission.C2D_MESSAGE" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<service android:name="com.parse.PushService" />
<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.myapp.main" />
</intent-filter>
</receiver>
To enable PPNS support, please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<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>
02-25 14:12:25.534  10046-10046/com.myapp.main E/com.parse.push﹕ successfully subscribed to the broadcast channel.

android:name="com.myapp.main.permission.permission.C2D_MESSAGE"

能改成只有一个"permission"吗?

我将清单更改为:

<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.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>
    <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.vitrin.main" />
        </intent-filter>
    </receiver>

我仍然得到那个错误 + :

02-25 15:44:33.042  32710-32710/com.myapp.main E/com.parse.PushService﹕      PushService somehow started even though this device doesn't support push.
02-25 15:44:33.042  32710-32710/com.myapp.main E/com.parse.PushService﹕ Started push service even though no push service is enabled: Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.myapp.main cmp=com.myapp.main/com.parse.PushService (has extras) }
02-25 15:45:10.508  32710-32710/com.myapp.main E/com.parse.PushService﹕ Started push service even though no push service is enabled: Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.myapp.main cmp=com.myapp.main/com.parse.PushService (has extras) }

但由于某种原因它正在工作!!