GCM推送通知在Android App中无效

时间:2016-04-24 09:05:11

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

推送通知在我的应用中无效。

当我发送推送通知时,它会显示如下消息:

GCM HTTP status: 200
GCM response body: {"multicast_id":5052582973644051315,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}

我的清单代码如下:

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

    <permission
        android:name="com.scryp.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"></permission>

    <uses-permission android:name="com.skryp.permission.MAPS_RECEIVE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <permission android:name="com.example.gcm.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:name=".activities.SkrypApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity
            android:name="com.scryp.activities.SplashActivity"
            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>

        <service
            android:name="com.scryp.activities.PushNotificationService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>

        <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.scryp.activities" />
            </intent-filter>
        </receiver>

        <activity
            android:name="com.scryp.activities.LoginActivity"
            android:label="@string/title_activity_login"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateAlwaysHidden" />
        <activity
            android:name="com.scryp.activities.SignupActivity"
            android:label="@string/title_activity_signup"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.scryp.activities.ForgotPasswordActivity"
            android:label="@string/title_activity_forgot_password"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.scryp.activities.ProfileActivity"
            android:label="@string/title_activity_profile"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.scryp.activities.CouponActivity"
            android:label="@string/title_activity_coupon"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.scryp.activities.HomeActivity"
            android:label="@string/title_activity_home"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name="com.scryp.activities.CouponDetailActivity"
            android:screenOrientation="portrait"></activity>
        <activity
            android:name="com.scryp.activities.DownloadCouponActivity"
            android:screenOrientation="portrait"></activity>
        <activity
            android:name="com.scryp.activities.TutorialActivity"
            android:screenOrientation="portrait"></activity>
        <activity android:name="com.facebook.FacebookActivity" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyB4rU0s2yS-3RGu5GQOb_L_JG6_H5toy60" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
    </application>

</manifest>

1 个答案:

答案 0 :(得分:1)

<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

将com.example.gcm更改为com.scryp: