skip to Main Content

I am using firebase_messaing inside my Flutter app. I can receive notifications on the Android Simulator, but the icon is just a bordered circle:

enter image description here

How can I change that icon?

2

Answers


  1. By default, Firebase messaging gets the app icon as the notification icon.

    It displays like that because emulators and some Android devices, don’t decode the icon on the notification bar if it is not transparent, make sure to make the app icon transparent and it will be visible.

    If you want you can customize the icon by doing this:

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_stat_ic_notification" />
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />
    

    For more information, check https://firebase.google.com/docs/cloud-messaging/android/client

    Login or Signup to reply.
  2. void showFlutterNotification(RemoteMessage message) {
      RemoteNotification? notification = message.notification;
      AndroidNotification? android = message.notification?.android;
      if (notification != null && android != null && !kIsWeb) {
        flutterLocalNotificationsPlugin.show(
          notification.hashCode,
          notification.title,
          notification.body,
          NotificationDetails(
            android: AndroidNotificationDetails(
              channel.id,
              channel.name,
              channelDescription: channel.description,
              // TODO add a proper drawable resource to android, for now using
              //      one that already exists in example app.
              icon: 'launch_background',
            ),
          ),
        );
      }
    }
    

    icon: ‘launch_background’ you can try to change icon from here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search