Android通知图标将不会出现,并且始终是正方形/圆形

问题描述 投票:2回答:1

我的应用程序中有两种通知。我有一个foreground服务,该服务会在启用应用程序的地理位置并将其发布到API时填充通知栏。

第二种类型是云消息传递firebase通知,目前从控制台触发,但最终会从后端服务器发布到firebase云消息传递API触发。

foreground服务似乎使用我的应用程序的启动器图标,而不管我做什么,并且FCM通知使用默认的android通知图标(圆圈中的小android徽标)。

但是,它们都使用API​​上色以更改其上的重音。

[在两种情况下,我都尝试使用drawable/ic_stat_home,其中ic_stat_home是图像,具有透明背景和房屋的alpha /白色图标(从https://romannurik.github.io/AndroidAssetStudio/生成并提取到res文件夹)

这是我的清单(仅适用于问题的FCM部分)

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

我的图标或实现是否存在问题?编辑:FirebaseMessaging: Icon with id: 2130903040 uses an invalid gradient. Using fallback icon.是我在Logcat中看到的错误。但是,当我打开图像时,它是全白的,只有透明性,我想念什么?

react-native android-notifications react-native-firebase
1个回答
0
投票
例如:-Gmail IconGmail Notification图像中间没有任何东西,只是圆圈的形状...这称为透明背景但可以使用.setColor()方法更改它,如下代码所示。

这里是设置通知图标颜色的代码:-

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { notificationBuilder.setSmallIcon(R.drawable.appypie_small); notificationBuilder.setColor(getResources().getColor(R.color.notification_color)); } else { notificationBuilder.setSmallIcon(R.drawable.appypie_small); }

© www.soinside.com 2019 - 2024. All rights reserved.