GCM 推送通知未恢复

GCM Push Notification Not Revived

你可以在下面找到清单文件,他们的 GCM 推送通知配置有什么问题吗类?

在 android 设备上根本没有收到通知,但苹果设备会收到通知

 package="ac.iec"
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

<permission
    android:name="ac.iec.permission.C2D_MESSAGE"
    android:protectionLevel="signature"/>

<uses-permission android:name="ac.iec.permission.C2D_MESSAGE"/>
    <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="ac.iec"/>
        </intent-filter>
    </receiver>
           <service
        android:name=".pushnotification.GCMIntentService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        </intent-filter>
    </service>
    <service
        android:name=".pushnotification.MyInstanceIDListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID"/>
        </intent-filter>
    </service>

<receiver> 标签和 <services> 标签应该在 <application> 标签中。

或者,如果您支持 4.4 之前的版本,则应添加注册操作。 https://developers.google.com/cloud-messaging/android/client

If you want to support pre-4.4 KitKat devices, add the following action to the intent filter declaration for the receiver:

您错过了一些 user permisssionreciver 这样设置的内容。

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

此权限设置

<permission
    android:name="your package name.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

此用户权限

<uses-permission android:name="your package.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />

此代码设置在application方。

 <!-- GCM Receiver -->
   <!-- this package name set your broadcast receiver class -->
    <receiver

        android:name="package name .GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>

            <!-- Receives the actual messages. -->
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <!-- Receives the registration id. -->
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="main package name" />
        </intent-filter>
    </receiver>

在您的清单文件中尝试此代码。 谢谢。