有什么简单的方法可以在Flutter中显示通知吗?我已经尝试过使用这个插件:
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
NotificationAppLaunchDetails notificationAppLaunchDetails;
Future<void> _showNotification(String msg) async {
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'696969', 'FCPN', 'FCPN Example',
importance: Importance.Max, priority: Priority.High, ticker: 'ticker');
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0, 'plain title', msg, platformChannelSpecifics,
payload: 'item x');
}
但是我有空指针
对于iOS,您必须配置Xcode文件。
将以下行添加到iOS项目的AppDelegate.m/AppDelegate.swift
文件中的didFinishLaunchingWithOptions
方法
查看pub.dev上的flutter_local_notifications
自述以了解更多信息。