Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter local notification body not showing all notification text (flutter_local_notifications package)

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);
  }
like image 511
mohmdezeldeen Avatar asked Jul 28 '19 09:07

mohmdezeldeen


People also ask

How do I show local notification in Flutter?

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.

How do I show multiple notifications on Flutter?

This is whole code: import 'package:flutter/material. dart'; import 'package:flutter_local_notifications/flutter_local_notifications.

How do I add icons to my local notification Flutter?

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'.

How to use local notifications in flutter?

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

Does flutter_local_notifications require the timezone package?

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.

Does flutter support iOS and Android?

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.

How do I schedule full-screen intent notifications in flutter?

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.


1 Answers

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(''),
    );
like image 178
ahmed el-shafei Avatar answered Oct 06 '22 07:10

ahmed el-shafei