Firebase 通知始终显示空白图标

2024-01-15

我是新来的FCM。我无法使FCM使用我的应用程序图标作为通知图标,该图标始终是白色的空白图标。

我导入了一个图标mipmap文件夹,但似乎没有任何改变。正如一些人所说,这是因为棒棒糖通知在这个问题中 https://stackoverflow.com/questions/28387602/notification-bar-icon-turns-white-in-android-5-lollipop

但问题是,FCM通知自动弹出,我无法让通知生成器覆盖该图标。我怎样才能改变它?


这是 FCM 的默认行为。当应用程序在后台时,它将采用白色图标。

使用此标签并将其放入您的清单中。对我来说这有效。希望它也适合你。确保元数据位于应用程序内部,如中提到的示例快速开始 https://github.com/firebase/quickstart-android/blob/master/messaging/app/src/main/AndroidManifest.xml#L16

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    tools:ignore="GoogleAppIndexingWarning">
    <!-- [START fcm_default_icon] -->
    <!-- Set custom default icon. This is used when no icon is set for incoming notification messages. -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_stat_ic_notification" />
    <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
         notification message. -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />
    <!-- [END fcm_default_icon] -->
    <!-- [START fcm_default_channel] -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_channel_id"
        android:value="@string/default_notification_channel_id" />
    <!-- [END fcm_default_channel] -->
    <activity
        android:name=".EntryChoiceActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".kotlin.MainActivity" />
    <activity android:name=".java.MainActivity" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Firebase 通知始终显示空白图标 的相关文章

随机推荐