logcat 推送未正确启用的报告

logcat report of push not being enabled correclty

我使用 Parse 作为我的应用程序的后端,我使用他们的 quick start guide 来设置推送通知。

我是一步步跟着做的,没有被催。当我启动应用程序时,我也会在 logcat 中收到此报告

08-22 18:46:34.785    4325-4325/maxbleggi.afstudentplanner D/com.parse.ParsePushChannelsController﹕ Tried to subscribe or unsubscribe from a channel, but push is not enabled correctly. 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 use GCM for push: 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="maxbleggi.afstudentplanner.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="maxbleggi.afstudentplanner.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="maxbleggi.afstudentplanner" />
</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.OPEN" />
<action android:name="com.parse.push.intent.DELETE" />
</intent-filter>
</receiver>

但我遵循了指南,我相信我的清单是正确的

在这里

<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="maxbleggi.afstudentplanner" >

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<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="com.google.android.c2dm.permission.RECEIVE" />

<permission
    android:name="maxbleggi.afstudentplanner.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="maxbleggi.afstudentplanner.permission.C2D_MESSAGE" />

<application
    android:name=".utils.InitializeParse"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".activities.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activities.RegisterActivity"
        android:label="@string/title_activity_register" >
    </activity>
    <activity
        android:name=".activities.RegisterPart_2Activity"
        android:label="@string/title_activity_register_part_2" >
    </activity>
    <activity
        android:name=".activities.RegisterPart2TeacherActivity"
        android:label="@string/title_activity_register_part2_teacher" >
    </activity>
    <activity
        android:name=".activities.SplashScreenActivity"
        android:label="@string/title_activity_splash_screen" >
    </activity>
    <activity
        android:name=".activities.RegisterPart_3TeacherActivity"
        android:label="@string/title_activity_register_part_3_teacher" >
    </activity>

    <!--<meta-data android:name="com.parse.push.notification_icon"/>
               android:resource="@drawable/ic_stat_bt"-->

    <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.parse.ParsePushBroadcastReceiver"
               android:exported="false">
         <intent-filter>
             <action android:name="com.parse.push.intent.RECEIVE" />
             <action android:name="com.parse.push.intent.OPEN" />
             <action android:name="com.parse.push.intent.DELETE" />
         </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="maxbleggi.afstudentplanner" />
         </intent-filter>
     </receiver>

 </application>

 </manifest>

这里是我开始解析的地方

    ...
    Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
    ParseInstallation.getCurrentInstallation().saveInBackground();

    ParsePush.subscribeInBackground("", new SaveCallback()
    {
        @Override
        public void done(ParseException e)
        {
            if (e == null)
            {

            } else
            {

            }
        }
    });

当我使用我的设备时,我没有收到此 logcat 报告,但当我使用模拟器时,我会收到此报告

如果使用 Genymotion as emulator and it does not have Google Apps installed on it, that might cause the issue. Try to Install ARM translation and check again. For more see Unable to get push notification when using Genymotion as my emulator of my android app

我知道可能存在复杂的模拟器问题,但选择一个简单的模拟器似乎缺少权限

<uses-permission android:name="maxbleggi.afstudentplanner.permission.C2D_MESSAGE" />