I want like this. I use FCM for push notifications. Notifications arrive but doesn’t appear like heads-up. It only appears on status bar.
Am I doing something wrong or do I have to something else?
AwesomeNotifications().initialize(
// set the icon to null if you want to use the default app icon
null,
[
NotificationChannel(
channelGroupKey: 'channel_group_key',
channelKey: 'channel_key',
channelName: 'channel_name',
channelDescription: 'channel_description',
importance: NotificationImportance.Max,
)
],
debug: true,
);
Note: On iOS, you need to request for notifications permissions. And on Android 11, you need to request for fullScreenIntent. Here’s the code (put it in initState() or whatever):
AwesomeNotifications().isNotificationAllowed().then(
(isAllowed) {
//It would be more appropriate if you can show your own dialog
//to the user before requesting the notifications permissons.
if (!isAllowed) {
AwesomeNotifications().requestPermissionToSendNotifications(
permissions: [
NotificationPermission.Alert,
NotificationPermission.Sound,
NotificationPermission.Badge,
NotificationPermission.Vibration,
NotificationPermission.Light,
NotificationPermission.FullScreenIntent,
],
);
}
}
);
And how to create the notification, put it whenever you need to fire the notification:
2
Answers
Did you want to show your app notification in the notification bar if yes
you should try this package
flutter_local_notifications: ^16.3.0
as you can show on top of image
To create heads-up notifications in Flutter you need awesome_notifications package
In your main.dart file:
Android initialization only:
Note: On iOS, you need to request for notifications permissions. And on Android 11, you need to request for fullScreenIntent. Here’s the code (put it in initState() or whatever):
And how to create the notification, put it whenever you need to fire the notification: