使用Parse推送通知错误

时间:2014-05-14 17:28:08

标签: android push-notification parse-platform google-cloud-messaging

尝试使用Parse添加推送通知。调试告诉我在清单中添加已经存在的缺失声明。我在代码中错误地放置了我的代码吗? (使用android SDK的第一个应用程序)我已经尽可能接近Parse示例代码,三重检查教程,现在关于想法

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

    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <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" />

    <!--
      IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
      to match your app's package name + ".permission.C2D_MESSAGE".
    -->
    <permission android:protectionLevel="signature"
        android:name="com.megger.cablecalcplustwo.pushnotifications.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.megger.cablecalcplustwo.pushnotifications.permission.C2D_MESSAGE" />



    <application



        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.Black.NoTitleBar">
        <activity
            android:name="com.megger.cablecalcplustwo.CableCalcActivity"
            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="com.megger.cablecalcplustwo.CcActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.CalculatorActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuideActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.CablesActivity" android:label="@string/app_name" android:theme="@style/AlphaActivity"/>
        <activity android:name="com.megger.cablecalcplustwo.ContactActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuideMultifunctionActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuidePatActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuideLoopActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuideInsulationActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuideElectriciansActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuideClampActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.GuidePageActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.WebViewActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.AboutActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.VideoViewActivity" android:label="@string/app_name" android:configChanges="orientation" />
        <activity android:name="com.megger.cablecalcplustwo.VideoActivity" android:label="@string/app_name" />
        <activity android:name="com.megger.cablecalcplustwo.CompetitionsAndEvents" android:label="@string/app_name" />

        <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.megger.cablecalcplustwo.pushnotifications" />
            </intent-filter>
        </receiver>




        <compatible-screens>

            <screen android:screenSize="small" android:screenDensity="ldpi" />
            <screen android:screenSize="small" android:screenDensity="mdpi" />
            <screen android:screenSize="small" android:screenDensity="hdpi" />
            <screen android:screenSize="small" android:screenDensity="xhdpi" />

            <screen android:screenSize="normal" android:screenDensity="ldpi" />
            <screen android:screenSize="normal" android:screenDensity="mdpi" />
            <screen android:screenSize="normal" android:screenDensity="hdpi" />
            <screen android:screenSize="normal" android:screenDensity="xhdpi" />

            <screen android:screenSize="large" android:screenDensity="ldpi" />
            <screen android:screenSize="large" android:screenDensity="mdpi" />
            <screen android:screenSize="large" android:screenDensity="hdpi" />
            <screen android:screenSize="large" android:screenDensity="xhdpi" />

            <screen android:screenSize="xlarge" android:screenDensity="ldpi" />
            <screen android:screenSize="xlarge" android:screenDensity="mdpi" />
            <screen android:screenSize="xlarge" android:screenDensity="hdpi" />
            <screen android:screenSize="xlarge" android:screenDensity="xhdpi" />



        </compatible-screens>


    </application>
</manifest>

logcat的

05-14 18:04:52.415  29036-29055/com.megger.cablecalcplustwo 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.megger.cablecalcplustwo.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.megger.cablecalcplustwo.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.megger.cablecalcplustwo" />
    </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>

1 个答案:

答案 0 :(得分:4)

您应该将所有显示com.megger.cablecalcplustwo.pushnotifications的地方更改为com.megger.cablecalcplustwo,因为这是您应用的包名称。