我正在使用谷歌推送通知,它一直运作到现在为止, 目前,推送通知不起作用,因为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>
答案 0 :(得分:2)
尝试更改此内容:
<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" />
答案 1 :(得分:1)
我不确定交叉停止的地方,但我仍在使用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>