android - oreo(8.0) 或更高版本中的 GCMBroadcastReceiver 不工作

标签 android google-cloud-messaging

GCMBroadcastReceiver 未使用 list 或动态注册

<receiver
            android:name="com.ee.nowmedia.core.pushnotification.PushBroadcastReceiver"
            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="com.ee.nowmedia.core.pushnotification" />
            </intent-filter>
        </receiver>

最佳答案

自 2018 年 4 月 10 日起,Google 已弃用 GCMGCM 服务器和客户端 API 已弃用,最快将于 2019 年 4 月 11 日删除。将 GCM 应用程序迁移到 Firebase Cloud Messaging (FCM) ,它继承了可靠且可扩展的 GCM 基础架构,以及许多新功能。查看migration guide了解更多。在 Google Cloud Messaging -- DEPRECATED 4/10/2018 阅读更多内容文档

所以代码

<receiver
    android:name="com.google.android.gms.gcm.GcmReceiver"
    android:exported="true"
    android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        ......
    </intent-filter>
</receiver>

自 8.0 起以及 2019 年 4 月 11 日之后对每个 API 都无用。

关于android - oreo(8.0) 或更高版本中的 GCMBroadcastReceiver 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51782425/

相关文章:

android - Urban Airship 自动抛出通知

android - 为什么我的 TabHost 的 FrameLayout 的唯一 child 加载了 visibility = View.GONE?

android - 在android中滑动

android - Android Studio 3.2 升级上的 java.lang.VerifyError

xamarin - 如何使用 Google Cloud Messaging 将通知推送到 iOS

android - 将我的应用程序的 GCM key 共享给第三方供应商是否安全?

android - GCM : how to avoid throttling

android - 用于显示 json 的 ListView 和列表适配器

java - 如何从 Android 调用 WordNet? [Android 版 Wordnet API]

android - GCM 在模拟器中有效,但在移动设备中无效