Search code examples
flutterandroid-studiopush-notification

How can a customised icon be set for Android Push Notifications?


Having recent success with sending and receiving my very first Firebase Cloud Message to an Android Emulator, I noticed that there was no logo on the notification. The cloud message's title and body appeared on the notification but not a logo.

My first step to add an icon to the notifications was to reference a logo image within my the payload. Doing this made no difference.

So at this stage my question is, how is the Android side of Flutter communicated with in order for the Android notifications to receive a customised icon and not the default Flutter icon?


Solution

  • If you are using flutter local notifications package then you can add a resource to the android settings while initialising the notification service.

    In android/app/src/main/res/mipmap you can add a custom png different from you app icon and mention that in the Android Settings.

     const androidNotificationDetails = AndroidNotificationDetails(
          'App Name',
          'Channel_Id',
          channelAction: AndroidNotificationChannelAction.createIfNotExists,
          priority: Priority.high,
          playSound: true,
          largeIcon:
          DrawableResourceAndroidBitmap('@mipmap/custom_png'),
        );
    

    Something like this can be done and the package will communicate with android to get the image.