GCM 推送通知未恢复 [英] GCM Push Notification Not Revived

本文介绍了GCM 推送通知未恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Below you can find the manifest file, is their anything wrong with configuration of GCM push notification classes ?

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

 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>

推荐答案

您错过了一些用户权限 &reciver 就是这样设置的.

You have miss some user permisssion & reciver set like this way.

<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" />

此代码设置在应用程序端.

 <!-- 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>

在您的清单文件中试试这个代码.谢谢.

try this code in your manifest file. Thanks.

这篇关于GCM 推送通知未恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆