【问题标题】:Flutter local notification body not showing all notification text (flutter_local_notifications package)Flutter 本地通知正文未显示所有通知文本(flutter_local_notifications 包)
【发布时间】:2019-07-28 09:56:41
【问题描述】:

我在 Flutter 应用程序中使用 flutter_local_notifications: ^0.7.1+3 来推送日程通知。一切都很好,但我的通知正文中的问题是它只显示一行文本,我无法扩展或拉伸通知以显示所有通知正文。

这是我的尝试:

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);
  }

【问题讨论】:

  • 我通过添加 style 属性找到了解决方案:style: AndroidNotificationStyle.BigText
  • 如果您找到了解决方案,如何创建自己的答案?您可以在 48 小时后接受。
  • 查看@ahmedel-shafei 在his question 中的解决方案。
  • 当我的应用程序完全关闭时会怎样。谈论android托盘何时处理通知

标签: flutter dart localnotification


【解决方案1】:

在[AndroidNotificationDetails()]中添加[BigTextStyleInformation('')]

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(''),
    );

【讨论】:

  • 当我的应用程序完全关闭时会怎样。谈论android托盘何时处理通知
  • 你找到如何在托盘中显示所有通知内容了吗? @b.john
  • 我没有,所以我离开了这个功能。但如果您得到解决方案,请分享。
猜你喜欢
  • 2019-09-06
  • 2021-10-16
  • 2022-01-21
  • 2018-06-11
  • 1970-01-01
  • 1970-01-01
  • 2022-11-29
  • 1970-01-01
相关资源
最近更新 更多