Home > other >  How to change local notification icon?
How to change local notification icon?

Time:06-10

I made the local notification icon with png file. However, in android, the icon looks transparent. It looks good in ios app. How can I show the original icon image as a notification icon?

ios notification icon enter image description here

android notification icon enter image description here

Notification code

import 'package:flutter_local_notifications/flutter_local_notifications.dart';
// import 'package:timezone/data/latest_all.dart' as tz;
// import 'package:timezone/timezone.dart' as tz;

final notifications = FlutterLocalNotificationsPlugin();

initNotification() async {

  var androidSetting = const AndroidInitializationSettings('ic_launcher');

  var iosSetting = const IOSInitializationSettings(
    requestAlertPermission: true,
    requestBadgePermission: true,
    requestSoundPermission: true,
  );

  var initializationSettings = InitializationSettings(
      android: androidSetting,
      iOS: iosSetting
  );
  await notifications.initialize(
    initializationSettings,
  );
}

showNotification() async {

  var androidDetails = const AndroidNotificationDetails(
    'ID',
    'notification',
    priority: Priority.high,
    importance: Importance.max,
    // color: Color.fromARGB(255, 255, 0, 0),
  );

  var iosDetails = const IOSNotificationDetails(
    presentAlert: true,
    presentBadge: true,
    presentSound: true,
  );

  notifications.show(
      1,
      'title1',
      'content1',
      NotificationDetails(android: androidDetails, iOS: iosDetails)
  );
}

CodePudding user response:

I have the same problem today. For android, you need to change the icon, android -> app -> main -> res -> drawable and that name put inside

var androidSetting = const AndroidInitializationSettings('ic_launcher');

inside but for iOS I don't know where to change

CodePudding user response:

You can try this for android icon

https://medium.com/nonstopio/change-the-firebase-notification-icon-in-a-flutter-245b7f7dc546

  • Related