Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

notification icon dones't show in flutter andriod app local_notification_flutter

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

notification icon doesn't show like this

enter image description here

I put in this path

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

here is my code for icon:

 final settingsAndroid = AndroidInitializationSettings('app_icon');
 final settingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotification(payload));
 final settingsIOSgeneral = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotificationgeneral(payload));
 notifications.initialize(InitializationSettings(settingsAndroid, settingsIOS), onSelectNotification: onSelectNotification);

Can Any one help me please how can I preview my icon in notification ?

like image 543
Eman Fateen Avatar asked Aug 05 '19 16:08

Eman Fateen


People also ask

How do I add icons to my local notification Flutter?

Setup Icon for Notification on status bar:Copy the app icon at android/app/src/main/res/drawable/ folder. Here, we have the icon "notification_icon. png" in the drawable folder, it is only for android. For, iOS, it will have an icon of the app.

How do I show notifications on Flutter?

Flutter local notifications setupflutter_local_notifications is a cross-platform plugin for displaying local notifications. The plugin has several features you can implement to customize notifications on the supported platforms. To get started, you'll need to install and set up the package for Android and iOS.

How do I display images in Flutter local notification?

To achieve an image on local notification, first add the awesome_notifications Flutter package by adding the following lines in pubspec. yaml file. awesome_notifications is the best flutter package we got to show local notifications in the Flutter app.


2 Answers

I did the following and it worked for me:

  1. Create a transparent and white notification icon (you can use the following tool: AndroidAssetStudio )

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

Folder Structure

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

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.

Android Manifest

  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

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

colors.xml

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

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

like image 171
user2549980 Avatar answered Nov 02 '22 13:11

user2549980


This could be because the icon image is not transparent -- Try the notification icon generated from this tool. Also check this question Android Push Notifications: Icon not displaying in notification, white square shown instead

like image 41
Sandeep Chayapathi Avatar answered Nov 02 '22 15:11

Sandeep Chayapathi