【问题标题】:How to set a Flutter Custom Notification Icon ?,because there is no default notification icon in flutter for fcm如何设置 Flutter 自定义通知图标?,因为 fcm 的 Flutter 中没有默认通知图标
【发布时间】:2024-01-02 21:36:01
【问题描述】:

当我使用 fcm(firebase 云消息传递)时,我想设置一个自定义通知图标以显示在我的 Flutter 应用程序的通知面板中,但只有一个灰色圆圈出现,没有图标。

【问题讨论】:

    标签: flutter firebase-cloud-messaging icons


    【解决方案1】:

    找了好久终于找到答案了:

    1. 使用此tool 创建自定义通知图标。
    2. 将生成的图标列表粘贴到android/app/src/main/res
    3. 转到您的清单 android/app/src/main/AndroidManifest.xml 并在 application(不是 activity)标签中添加以下元数据。
    {<meta-data
    
              android:name = "com.google.firebase.messaging.default_notification_icon"
              android:resource = "@drawable/ic_notification"/>
              <meta-data
    android:name="com.google.firebase.messaging.default_notification_color"
    android:resource="@color/colorPrimary" />}
    
    1. 如果 res/values 中没有 colors.xml,请创建一个:
    2. 完成!,应该可以了,如果不行,请告诉我。

    问题讨论here

    【讨论】:

      最近更新 更多