9

I have an application using Package Flutter Local Notification for showing notifications. Everything is fine, I can show the notification. The problem is my image as icon notification does not show, only full color of my image.

What I have done:

  • Setting InitLocalNotification like documentation

    void initLocalNotification() async {
        _androidInitializationSettings = AndroidInitializationSettings('app_icon');
        _iosInitializationSettings = IOSInitializationSettings(
          onDidReceiveLocalNotification: _onDidReceiveLocalNotification,
        );
    
        _initializationSettings = InitializationSettings(
          _androidInitializationSettings,
          _iosInitializationSettings,
        );
    
        await _flutterLocalNotificationsPlugin.initialize(
          _initializationSettings,
          onSelectNotification: _onSelectNotification,
        );
      }
    
  • Set structure folder like documentation

  • Resize my logo like logo in documentation (Width : 36px , Height : 36px , Background : Transparant, Extension : .png)

    enter image description here

Even though I have done the above method, my image icon is not showing, only the color.

Result (does not work)

After that, I tried to change my image with image from documentation, and that is working. Image icon is shown in notification.

Image from documentation

enter image description here

Result (works)

Did I missed something?

Zeffry Reynando
  • 3,445
  • 12
  • 49
  • 89
  • Maybe it has to do with the way you generate the icon. Since do you have android studio? Try Image Asset! – unbalanced_equation Apr 18 '20 at 09:22
  • @Moqbel before i try to resize the image in online site, i already using this for created icon image https://developer.android.com/studio/write/image-asset-studio#access. But icon notification still only show color not the image – Zeffry Reynando Apr 18 '20 at 09:40
  • 1
    plz share your AndroidManifest.xml and also the folder structure of where the image is saved. You can also refer to this solution - https://github.com/flutter/flutter/issues/17941#issuecomment-622268132 – user2549980 Sep 04 '20 at 18:36
  • Please check this link in detail: https://pub.dev/packages/flutter_local_notifications#custom-notification-icons-and-sounds – RuslanBek May 09 '21 at 07:40
  • 2
    check this answer https://stackoverflow.com/a/67455360/15236786 – RuslanBek May 09 '21 at 09:06
  • Have you tried checking this [SO post](https://stackoverflow.com/questions/45318614/why-is-my-smallicon-for-notifications-always-greyed-out/45318726#45318726)? – MαπμQμαπkγVπ.0 May 12 '21 at 21:33
  • Does this answer your question? [notification icon dones't show in flutter andriod app local\_notification\_flutter](https://stackoverflow.com/questions/57362439/notification-icon-donest-show-in-flutter-andriod-app-local-notification-flutter) – Sisir Mar 11 '22 at 17:43

2 Answers2

4

If your icon displays as rectangle on release build and you are sure that your icon matches notification icon guidelines then you should try to disable shrinking resources in build.gradle:

buildTypes {
    release {
        signingConfig signingConfigs.release
        shrinkResources false
    }
}
Kuba
  • 53
  • 7
0

For anyone looking at this. The problem here comes from the shape of the icon. In most android version the notification icon is just a shape filled with a color (such as the F of flutter). A rectangular icon with no transparency will be a rectangle filled with a color.

Some constructor, such as Samsung, show the actual image in some of their software version.

gbaccetta
  • 4,449
  • 2
  • 20
  • 30