由于没有收到GCM推送通知(Android) [英] Not receiving push notifications from GCM (Android)

查看:201
本文介绍了由于没有收到GCM推送通知(Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个链接来测试我的推送通知。昨晚它工作得很好,早上醒来,我不再接收推送通知。我测试了它之前,我写的任何新的code。用于测试的设备是三星Galaxy S5,操作系统是棒棒糖。

I'm using this link to test my push notifications. Last night it worked fine, woke up this morning and I'm no longer receiving push notifications. I tested it before I wrote any new code. The device used for testing is a Samsung Galaxy S5, OS is Lollipop.

下面是我的表现,让我知道如果你需要看我的任何服务。

Here is my manifest, let me know if you need to see any of my services.

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

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

    <application
        ....
        ....

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

        <service
            android:name=".services.MyGcmListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
        <service
            android:name=".services.MyInstanceIDListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID" />
            </intent-filter>
        </service>

我没有得到任何错误,它说,该消息来自我的服务器和上面的测试链接发送成功。我试着卸载应用程序,并生成一个新的令牌,它仍然没有工作。我还可以给每个我加载应用程序的时间成功地找回我的令牌。

I get no errors and it says the message is sent successfully from both my server and that testing link above. I've tried uninstalling the app and generating a new token, and its still not working. I am also able to retrieve my token successfully each time I load the app.

推荐答案

看看这个官方教程。看来你错过了你的包名称添加到权限。

Look at this official tutorial. Seems you missed to add you package name to permissions.

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

<uses-permission android:name="your.package.name.permission.C2D_MESSAGE" />

也是你MyGcmListenerService和MyInstanceIDListenerService来源将是有益的帮助(你如何获取和处理令牌等)。

Also sources of yours MyGcmListenerService and MyInstanceIDListenerService would be useful to help (how you obtain and handle token etc).

或者,如果你说,它的工作昨天罚款,尝试启用然后禁用飞行模式,或重新启动手机。

Or, if you say that its worked fine yesterday, try to enable and then disable airplane mode, or reboot the phone.

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

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