我可以将 android 中的默认推送通知图标从应用程序图标覆盖为自定义图标吗?

新手上路,请多包涵

我可以将 android 中的默认推送通知图标从应用程序图标覆盖为自定义图标吗?

当推送通知到来时,我使用默认的 firebase 实现在系统托盘中显示通知。因为我的应用程序图标是彩色的并且有渐变,所以当通知到来时,android 试图制作它的黑色/白色版本,并让它看起来像一个白色圆圈。

有没有办法将默认通知图标更新为其他东西而不是默认应用程序图标?

PS:期待一个需要在清单中更改配置并且不想使用 NotificationCompat.Builder 的解决方案

原文由 Shashank 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 484
1 个回答

您可以根据 https://firebase.google.com/docs/cloud-messaging/android/receive 在您的清单中使用它

    <!-- Set custom default icon. This is used when no icon is set for incoming notification
    messages.See README(https://github.com/firebase/quickstart-android/tree/master/messaging#custom-default-icon) for more. -->
    <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. See README
    (https://github.com/firebase/quickstart-android/tree/master/messaging#custom-default-color) for more. -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />

希望它能帮助人们。

原文由 elsennov 发布,翻译遵循 CC BY-SA 3.0 许可协议

推荐问题