I used flutter_local_notifications: ^0.7.1+3
in my Flutter app to push schedule notifications. All is well in this but the problem in my notification body is that it shows just one line of text, and I can't expand or stretch notification to show all the notification body text.
This is my try:
class NotificationUtil {
final notifications = FlutterLocalNotificationsPlugin();
final int checkOutNotifyId = 0;
NotificationUtil(BuildContext context) {
final settingsAndroid = AndroidInitializationSettings('ic_notify_icon');
final settingsIOS = IOSInitializationSettings(
onDidReceiveLocalNotification: (id, title, body, payload) =>
onSelectNotification(context));
notifications.initialize(
InitializationSettings(settingsAndroid, settingsIOS),
onSelectNotification: (context) async => onSelectNotification);
}
Future<void> showCheckOutNotify([int maximumCheckoutHours]) async {
await notifications.periodicallyShow(
checkOutNotifyId,
AttendanceConstants.SCHEDULE_NOTIFICATION_TITLE,
AttendanceConstants.SCHEDULE_NOTIFICATION_BODY +
'$maximumCheckoutHours Hour/s of your attendance',
RepeatInterval.Hourly,
_ongoing);
}
NotificationDetails get _ongoing {
final androidChannelSpecifics = AndroidNotificationDetails(
'your channel id',
'your channel name',
'your channel description',
importance: Importance.Max,
priority: Priority.High,
ongoing: true,
);
final iOSChannelSpecifics = IOSNotificationDetails();
return NotificationDetails(androidChannelSpecifics, iOSChannelSpecifics);
}
Flutter local notifications setupflutter_local_notifications is a cross-platform plugin for displaying local notifications. The plugin has several features you can implement to customize notifications on the supported platforms. To get started, you'll need to install and set up the package for Android and iOS.
This is whole code: import 'package:flutter/material. dart'; import 'package:flutter_local_notifications/flutter_local_notifications.
1. We have to define the app icon, In the above image you can see this 'new AndroidInitializationSettings('app_icon')' . Here app_icon is image name which we had put inside the drawable directory. If you didn't put that then you can use default icon for that you have to use '@mipmap/ic_launcher' instead of 'app_icon'.
Local Notifications In Flutter 1 Setup. To allow our application to use local notifications, we need to add the flutter_local_notifications package to our project. 2 Integration. ... 3 Use Cases - Showing A Notification. ... 4 Use Cases - Scheduling A Notification. ... 5 Canceling A Notification
As the flutter_local_notifications plugin already depends on the timezone package, it's not necessary for developers to add the timezone package as a direct dependency. In other words, the timezone package will be a transitive dependency after you add the flutter_local_notifications plugin as a dependency in your application.
Due to the fact that Flutter is a cross platform framework, every package that is created for it needs to support both iOS and Android devices. Because notifications are handled very differently between iOS and Android, there are several calibrations that need to be made when using the local notifications package.
If your application needs the ability to schedule full-screen intent notifications, add the following attributes to the activity you're opening. For a Flutter application, there is typically only one activity extends from FlutterActivity. These attributes ensure the screen turns on and shows when the device is locked.
add [ BigTextStyleInformation('') ] in [ AndroidNotificationDetails() ]
NotificationDetails get _ongoing {
final androidChannelSpecifics = AndroidNotificationDetails(
'your channel id',
'your channel name',
'your channel description',
importance: Importance.Max,
priority: Priority.High,
ongoing: true,
styleInformation: BigTextStyleInformation(''),
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With