多行推送通知颤动

时间:2020-08-21 16:09:26

标签: flutter dart

我正在使用flutter_local_notifications包进行推送通知。但是在通知托盘中,无论显示多少行,我都希望显示完整的消息。这是我写的代码

void showNotification(message) async {
    var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
      Platform.isAndroid ? 'com.headstrt.app' : 'com.headstrt.app',
      'Flutter chat demo',
      'your channel description',
      playSound: true,
      enableVibration: true,
      importance: Importance.Max,
      priority: Priority.High,
      styleInformation: BigTextStyleInformation(''),
    );

我还指定了一种样式,但仍然没有显示所有行。

enter image description here

2 个答案:

答案 0 :(得分:0)

这实际上不是您自己决定的。在Android中,单个通知的默认设置为在线。如果您想查看整个消息,则需要将通知向下拖动。

答案 1 :(得分:0)

在BigTextStyleInformation中,您必须指定传递给showNotification函数的消息值。

以我自己的代码为例;

  Future<void> _demoNotification(Map<String, dynamic> icerik) async {

  String longdata = icerik["notification"]["body"];

  var bigTextStyleInformation = BigTextStyleInformation(longdata); //multi-line show style

 AndroidNotificationDetails androidPlatformChannelSpecifics =
 AndroidNotificationDetails(

        'push_messages: 0',
        'push_messages: push_messages',
        'push_messages: A new Flutter project',
        importance: Importance.max,
        priority: Priority.high,
        showWhen: false,
        enableVibration: true,
        styleInformation: bigTextStyleInformation);

NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);

await flutterLocalNotificationsPlugin.show(
    1,
    icerik["notification"]["title"],
    icerik["notification"]["body"],
    platformChannelSpecifics,
    payload: icerik['data']['routing']);

    }