通知图标未显示在 flutter andriod 应用程序 local_notification_flutter 中 [英] notification icon dones't show in flutter andriod app local_notification_flutter

查看:95
本文介绍了通知图标未显示在 flutter andriod 应用程序 local_notification_flutter 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 flutter 新手,所以如果我的问题很简单,请不要杀我.

I'm new in flutter so please don't kill me if my question is easy.

通知图标不是这样显示的

notification icon doesn't show like this

我把这条路

\android\app\src\main\res\drawable

\android\app\src\main\res\drawable

这是我的图标代码:

final settingsAndroid = AndroidInitializationSettings('app_icon');最终设置IOS = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotification(payload));最终设置IOSgeneral = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotificationgeneral(payload));notification.initialize(InitializationSettings(settingsAndroid, settingsIOS), onSelectNotification: onSelectNotification);

任何人都可以帮助我如何在通知中预览我的图标?

推荐答案

我做了以下事情并且对我有用:

I did the following and it worked for me:

  1. 创建一个透明的白色通知图标(可以使用以下工具:AndroidAssetStudio)

下载 zip 文件夹,解压,你会看到它包含一个 res 文件夹,里面有不同的 drawable 文件夹.将 res 文件夹的内容复制并粘贴到android\app\src\main\res"中;路径

Download the zip folder, unzip and you'll see it contains a res folder with different drawable folders. Copy and paste the contents of the res folder in "android\app\src\main\res" path

  1. 然后打开 AndroidManifest.xml 文件并向其中添加以下几行:

  1. Then open the AndroidManifest.xml file and add the following lines to it:

ic_stat_calendar_today 是我的通知图标的名称.并且每个已粘贴的 drawable 文件夹都包含不同大小的同名图标.

ic_stat_calendar_today is the name of my notification icon. And each of the drawable folders that have been pasted contain a different size of icon with the same name.

  1. 如果您想更改图标的颜色,请查看上图.在通知图标标签后添加元数据标签

  1. If you want to change the color of the icon then check the above image. Add the metadata tag after the notification icon tag

转到android\app\src\main\res\values";并添加一个colors.xml文件

Go to "android\app\src\main\res\values" and add a colors.xml file

<color name="colorAccent">#00FF00</color>

我也在以下 Github 链中分享了这个答案-解决方案.

I have shared this answer in the following Github chain as well- Solution.

这篇关于通知图标未显示在 flutter andriod 应用程序 local_notification_flutter 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆