我使用下面一行代码进行Firebase消息传递配置和Flutter 通知配置,但是现在在集成到最新版本的Firebase消息传递后,它给出了错误
代码行
messaging.configure(onMessage: (Map<String, dynamic> message){}
DART分析中出错
error: The method 'configure' isn't defined for the type 'FirebaseMessaging'.
我使用下面一行代码进行Firebase消息传递配置和Flutter 通知配置,但是现在在集成到最新版本的Firebase消息传递后,它给出了错误
代码行
messaging.configure(onMessage: (Map<String, dynamic> message){}
DART分析中出错
error: The method 'configure' isn't defined for the type 'FirebaseMessaging'.
请判断以下示例.
@override
void initState() {
super.initState();
FirebaseMessaging.instance
.getInitialMessage()
.then((RemoteMessage message) {
if (message != null) {
Navigator.pushNamed(context, '/message',
arguments: MessageArguments(message, true));
}
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
RemoteNotification notification = message.notification;
AndroidNotification android = message.notification?.android;
if (notification != null && android != null) {
flutterLocalNotificationsPlugin.show(
notification.hashCode,
notification.title,
notification.body,
NotificationDetails(
android: AndroidNotificationDetails(
channel.id,
channel.name,
channel.description,
// TODO add a proper drawable resource to android, for now using
// one that already exists in example app.
icon: 'launch_background',
),
));
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print('A new onMessageOpenedApp event was published!');
Navigator.pushNamed(context, '/message',
arguments: MessageArguments(message, true));
});
}