Flutter Local Notification 仅在 Android 上显示点
Posted
技术标签:
【中文标题】Flutter Local Notification 仅在 Android 上显示点【英文标题】:Flutter Local Notification only showing dot on Android 【发布时间】:2021-07-20 13:21:53 【问题描述】:我在我的应用程序中使用Local Notifications,它在我的 iPhone 上运行良好,但是在我的 android 模拟器上触发通知时,它没有在屏幕顶部显示通知,而只有点:
通知实际上在通知中心看起来很好:
我要确保init
和我的电话instantNotification
看起来像这样:
Future initialize() async
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
AndroidInitializationSettings androidInitializationSettings =
AndroidInitializationSettings('app_icon');
iosInitializationSettings iosInitializationSettings =
IOSInitializationSettings();
final InitializationSettings initializationSettings =
InitializationSettings(
android: androidInitializationSettings,
iOS: iosInitializationSettings);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
//Instant Notifications
Future instantNofitication() async
var android = AndroidNotificationDetails('id', 'channel', 'description');
var ios = IOSNotificationDetails();
var platform = new NotificationDetails(android: android, iOS: ios);
await _flutterLocalNotificationsPlugin.show(
0,
'Demo instant notification',
'Tap to do something',
platform,
payload: 'Welcome to demo app',
);
我在这里错过了什么?
【问题讨论】:
【参考方案1】:您可以尝试使用此行将通知的重要性级别设置为最大值:
importance: Importance.max
您添加到 AndroidNotificationDetails 类实例。这将告诉 Android 操作系统通知对用户很重要,并且屏幕顶部的平视显示器(一个小弹出窗口)应该显示几秒钟。
我认为在阅读Android notification documentation 后会解决您的问题
【讨论】:
我换行了:var android = AndroidNotificationDetails('id', 'channel', 'description', importance: Importance.max, fullScreenIntent: true);
。但同样的问题......
还有其他想法吗? :(
@Chris 对不起,没有。以上是关于Flutter Local Notification 仅在 Android 上显示点的主要内容,如果未能解决你的问题,请参考以下文章
Flutter发送系统通知(flutter_local_notifications)
Flutter发送系统通知(flutter_local_notifications)
Flutter发送系统通知(flutter_local_notifications)
Flutter发送系统通知(flutter_local_notifications)