Firebase通知始终显示空白图标 [英] Firebase Notification Always shows blank icon

本文介绍了Firebase通知始终显示空白图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 FCM 的新手.我无法让 FCM 使用我的应用程序图标作为通知图标,并且该图标始终是白色的空白.

I'm new with FCM. I cannot make FCM use my app icon as notification icon and the icon is always a white blank one.

我将图标导入了 mipmap 文件夹,但似乎没有任何变化.就像一些家伙说的,这是因为棒棒糖通知在此问题

I imported an icon to mipmap folders but nothing seems changed. As some dude say that this is because of lollipop notification as in this question

但是问题是, FCM 通知会自动弹出,并且我无法使用通知"构建器来覆盖该图标.我该如何更改?

But the problem is, the FCM notification automatically pops up and I cannot get the Notification builder to override the icon. How can I change it?

推荐答案

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

This is the default behaviour of FCM. When app is in background it will take white icon.

使用此标签并将其放在清单中.对我来说,这行得通.希望它也对您有用.确保元数据位于应用程序内部,例如快速启动

Use this tag and put it in your Manifest. For me this worked. Hope it works for you too. Ensure meta-data is inside application like the example mentioned in quickstart

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

这篇关于Firebase通知始终显示空白图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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