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)
Even though I have done the above method, my image icon is not showing, only the color.
After that, I tried to change my image with image from documentation, and that is working. Image icon is shown in notification.
Did I missed something?
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
}
}
NotificationDetails(
android: AndroidNotificationDetails(
channel.id,
channel.name,
channelDescription: channel.description,
icon: '@mipmap/ic_notification_no_bg',
styleInformation: BigTextStyleInformation(''),
),
));
You need to provide a icon which does not have any background in AndroidNotificationDetails so App will pick this icon for Android version 11 for other versions it will pick default launcher Icon
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.