4

我正在使用谷歌推送通知,到目前为止它运行良好,目前推送通知不起作用,因为 onRegistered 从未启动。我认为问题出在清单中(因为问题是从未调用过接收器)但我不确定

这是我的清单

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

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

     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>     
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.SEND_SMS" />
     <uses-permission android:name="android.permission.WRITE_SMS"/>
     <uses-permission android:name="android.permission.RECEIVE_SMS" />
     <uses-permission android:name="android.permission.READ_SMS" />
     <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
     <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
     <uses-permission android:name="com.name.name.permission.C2D_MESSAGE" android:protectionLevel="normal" />  
    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.name.name.Disclaimer"
            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.name.name.Pago"
             >
        </activity>
        <activity android:name="com.name.name.MainActivity" android:screenOrientation="portrait"></activity>
        <activity android:name="com.name.name.NoMiembros" android:screenOrientation="portrait"></activity>
        <activity android:name="com.name.name.ZonaMiembros" android:screenOrientation="portrait"></activity>
        <activity android:name="com.name.name.PlayvideofromserverActivity" android:screenOrientation="portrait"></activity>
        <activity android:name="com.name.name.GoPromo" android:screenOrientation="portrait"></activity>
        <activity android:name="com.name.name.PantallaCarga" android:screenOrientation="portrait"></activity>


        <receiver android:name="com.google.android.gcm.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.name.name" />
            </intent-filter>
        </receiver>


        <receiver android:name=".SMSHandler$MessageReceiver" android:exported="true">
            <intent-filter android:priority="999">
            <action android:name="android.provider.Telephony.SMS_RECEIVED"></action>
            </intent-filter>
        </receiver>

        <service android:name=".GCMIntentService" />
    </application>


</manifest>
4

2 回答 2

3

尝试改变这个:

    <uses-permission android:name="com.name.name.permission.C2D_MESSAGE" 
android:protectionLevel="normal" />  

对此:

<permission android:name="com.name.name.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.name.name.permission.C2D_MESSAGE" />
于 2013-06-27T13:43:14.547 回答
3

我不确定交叉在哪里停止,但我仍在使用 C2DM 而不是 GCM,并且我将我的消息和注册接收器声明为本地类,而不是像你一样指向谷歌类。

    <receiver
        android:name=".utils.C2DMRegistrationReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" >
            </action>

            <category android:name="package.name.here" />
        </intent-filter>
    </receiver>
    <receiver
        android:name=".utils.C2DMMessageReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" >
            </action>

            <category android:name="package.name.here" />
        </intent-filter>
    </receiver>
于 2013-06-27T13:47:02.187 回答