'Flutter Local Notification only showing dot on Android
I am using Local Notifications for my app and it is working fine on my iPhone but when firing a Notification on my Android Simulator it is not showing the Notification on top of the screen but only the dot:
The Notification actually appears fine in the Notification Center:
I am making sure to init
and I a calling instantNotification
which looks like this:
Future initialize() async {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
AndroidInitializationSettings androidInitializationSettings =
AndroidInitializationSettings('app_icon');
IOSInitializationSettings iosInitializationSettings =
IOSInitializationSettings();
final InitializationSettings initializationSettings =
InitializationSettings(
android: androidInitializationSettings,
iOS: iosInitializationSettings);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
}
//Instant Notifications
Future instantNofitication() async {
var android = AndroidNotificationDetails('id', 'channel', 'description');
var ios = IOSNotificationDetails();
var platform = new NotificationDetails(android: android, iOS: ios);
await _flutterLocalNotificationsPlugin.show(
0,
'Demo instant notification',
'Tap to do something',
platform,
payload: 'Welcome to demo app',
);
}
What am I missing here?
Solution 1:[1]
You can try setting the importance level of the notification to a maximum with this line:
importance: Importance.max
which you add to the AndroidNotificationDetails class instance. This will tell to an Android OS that notification is important for the user and a heads-up display (a little popup) on top of the screen should be displayed for a few seconds.
I think that will solve your problem after reading an Android notification documentation
Solution 2:[2]
Adding on to @Antonio Valentic's answer, add the following properties to the AndroidNotificationDetails
importance: Importance.max,
priority: Priority.max,
fullScreenIntent: true,
enableVibration: true,
playSound: true
As quoted from the link:
- The user's activity is in fullscreen mode (the app uses fullScreenIntent).
- The notification has high priority and uses ringtones or vibrations on devices running Android 7.1 (API level 25) and lower.
- The notification channel has high importance on devices running Android 8.0 (API level 26) and higher.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Antonio Valentic |
Solution 2 | Victor Kwok |