我正在尝试确保我的应用收到Firebase通知时显示默认的Firebase通知图标和颜色。这样做是这样的:
onMessageReceived
函数中:NotificationCompat.Builder notificationCompatBuilder =
new NotificationCompat.Builder(
mContext.getApplicationContext(),
mContext.getString(R.string.notificationChannelID)
)
.setSmallIcon(R.drawable.eb_logo)
.setLargeIcon(
BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_launcher_round)
)
.setColor(Color.parseColor("#4dbeed"))
.setContentTitle(title)
.setContentText(content)
.setAutoCancel(true)
.setChannelId(channelID)
.setPriority(channelImportance);
AndroidManifest.xml
文件中,如下所示:<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/eb_logo" />
<!-- Notification details (colors etc.) for Firebase notifications. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/ebFirebaseNotificationColor" />
这在Android 8.0上完美运行。但是,在Android 9.0及更高版本上,尽管进行了上述更改,标题文本的颜色仍为默认的灰色。
我发现了一个链接:Change color of notification title (Android Studio)似乎暗示了这一点。
还有其他人会遇到同样的问题吗?我已经浏览了相关的Firebase云消息传递和android 9.0 changelogs,但是没有发现任何东西。
对此,任何帮助都是最欢迎的。