我有一个使用 GCM 的 andorid 应用程序(不是新的谷歌云消息传递 API)
通知在除 4.4(nexus 5)之外的所有 android 版本中都可以正常工作
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.PushNotifications"/>
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.PushNotifications"/>
</intent-filter>
</receiver>
在安卓 4.4 中。GCMBroadcastReciver 没有收到 com.google.android.c2dm.intent.RECEIVE 意图,只有 com.google.android.c2dm.intent.REGISTRATION
我知道旧的 GCM 已被弃用,但我不想使用 Google Play 服务和新的 API,而是想了解为什么它在 4.4 中不起作用
谢谢
完整的 Android 清单
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.PushNotifications" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19"/>
<supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="false"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Push permissions -->
<permission android:name="com.PushNotifications.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.PushNotifications.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:label="@string/app_name" android:debuggable="true" android:icon="@drawable/icon">
<activity android:name=".PushNotifications" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.PushNotifications.PushNotifications.NOTIFICATION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<!-- Preference Activity -->
<activity android:name="com.sample.common.WLPreferences" android:label="Sample"></activity>
<!-- Push service -->
<!-- In order to use the c2dm library, an application must declare a class with the name C2DMReceiver, in its own package, extending com.google.android.c2dm.C2DMBaseReceiver
It must also include this section in the manifest, replacing "com.google.android.apps.chrometophone" with its package name. -->
<service android:name=".GCMIntentService"/>
<service android:name=".ForegroundService"/>
<!-- Only google service can send data messages for the app. If permission is not set - any other app can generate it -->
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.PushNotifications"/>
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.PushNotifications"/>
</intent-filter>
</receiver>
</application>