flutter - 多行推送通知颤动
问题描述
我正在使用 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(''),
);
我也指定了一种样式,但仍然没有显示所有行。
解决方案
在 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']);
}
推荐阅读
- python - 为什么超出范围的变量仍然不能在 python 中工作?
- c# - 试图只返回没有异步/等待的任务
- django - 表单提交时出现 Django MultipleObjectsReturned 错误
- html - 如何使标题透明?
- python - ValueError:无法将输入数组从形状(48,64,3)广播到形状(0,1520,3)
- python-3.x - 如何将 Google 的 JWK 安全地存储在 Azure 中?
- python - 如何使用 Airflow 访问平面文件
- c# - 刚体的 addforce() 函数似乎无法正常工作
- animation - 重新投影地图纹理QGIS的问题
- python - 从父函数范围覆盖变量