android - Fcm 徽章不显示在 android 中

标签 android

我正在使用后端作为 python 实现 fcm,每当推送通知出现时我都需要徽章应用程序图标,但它不适用于除 moto g android 7 之外的大多数 android 手机。

我在 AndroidManifest.xml 中做了:

    <service
        android:name=".fcmnotification.Custom_FirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>

    <service
        android:name=".fcmnotification.Custom_FirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service>

这是我在 AndroidManifest.xml 中的元数据:

 <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/pushlogo"
        tools:ignore="ManifestResource"/>

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorPrimary" />

最佳答案

Badge 应用程序图标是在 Nougat 中引入的,即适用于 Stock Android 手机的 Android 7。因此,您上面的代码适用于 Moto G Android 7 而不是之前的版本。 现在,要在以前的 Android 版本上修复它,您需要了解应用启动器中的徽章图标是特定于启动器的。 获得以前版本支持的最佳方法是使用此库:ShortcutBadger

关于android - Fcm 徽章不显示在 android 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44048707/

相关文章:

java - 在 android ndk 上运行 pjsip 示例 pjsua 时出错

android - 为什么我的 recyclerview 从微调器中选择时有 2 行相同的数据?

android - 根据条件查询获取行数

java - 捕获现有的构建

android - Eclipse ADT 不是 Samsung s3 作为 android 设备 ??

android - 如何在 Android Studio 中查看已编译的 Jar 文件以进行顶层模拟?

android - 应用程序在 Nexus 6 Android marshmallow 上运行非常慢跳过 "n"帧

android - 仅限Android 4.1,Bitmap自动回收

android - 在哪里撤销在 Android 上授予的 Google API 权限?

android - 如何在不替换的情况下将参数传递给 fragment ?