【问题标题】:Flutter Firebase FCM notification always a white/grey square rather than the custom app iconFlutter Firebase FCM 通知始终是白色/灰色方块,而不是自定义应用程序图标
【发布时间】:2019-03-22 00:47:01
【问题描述】:

尝试了 Stackoverflow 的所有建议,但没有任何区别: 将其放入 AndroidManifest

 <application
    android:name="io.flutter.app.FlutterApplication"
    android:label="Honest"
    android:icon="@mipmap/ic_launcher">
    <!-- 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" />
    <activity

然后尝试将 ic 通知放在不同的文件夹中 - 没有区别!并将png图标直接放入drawables文件夹... 使用矢量和 png - 没有任何效果...仍然是相同的灰色方块...

res文件夹如下:

│   ├── launch_background.xml
│   └── orange_tick.xml

├── drawable-hdpi
│   ├── ic_stat_ic_notification.png
│   └── ic_stat_notification.png

├── drawable-mdpi
│   ├── ic_stat_ic_notification.png
│   └── ic_stat_notification.png

├── drawable-xhdpi
│   ├── ic_stat_ic_notification.png
│   └── ic_stat_notification.png

├── drawable-xxhdpi
│   ├── ic_stat_ic_notification.png
│   └── ic_stat_notification.png

├── drawable-xxxhdpi
│   ├── ic_stat_ic_notification.png
│   └── ic_stat_notification.png

├── mipmap-hdpi
│   └── ic_launcher.png
├── mipmap-mdpi
│   └── ic_launcher.png
├── mipmap-xhdpi
│   └── ic_launcher.png
├── mipmap-xxhdpi
│   └── ic_launcher.png
├── mipmap-xxxhdpi
│   └── ic_launcher.png
└── values
    ├── colors.xml
    ├── strings.xml
    └── styles.xml

任何人发现我做错了什么都行不通!

Flutter Doctor 完全干净,如果这有什么不同的话,Android 设备是带有 Android 7.0 的 Ulefone Power 2...

【问题讨论】:

  • 这个你搞定了吗?
  • 自上周以来,我一直在其他各个方面进行一些更改,但我认为主要是升级到 Androidx 并将所有 firebase 包更新到最新版本。在此之后,我现在开始看到自定义图标。耶!所以建议你也这样做,并从头开始重新构建 gradle。

标签: android firebase flutter firebase-cloud-messaging


【解决方案1】:

此问题的原因是没有设置自定义默认图标,也没有在通知负载中设置图标,如guide 中所述。如果最近刚刚添加了图标,您可以尝试使用重新启动来运行应用程序,以确保所有组件都包含在您的构建中。如果这不起作用,您还可以查看与此问题相关的 thread on GitHub

【讨论】:

  • 这是一个指导,但不是真正的答案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-03-30
  • 1970-01-01
  • 2018-07-04
  • 2019-06-01
  • 2022-01-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多