方法'configure'未针对"FirebaseMessaging"类型定义。任何人都可以正确重新输入我的代码吗?谢谢


  1. 推送通知码。我不明白如何使用firebase
  2. 实现在flutter中实现通知的新方法
import 'dart:io' show Platform;
import 'package:google_maps_flutter/google_maps_flutter.dart';
class PushNotificationService
{
final firebaseMessaging = FirebaseMessaging.instance;
Future initialize(context) async
{
firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
retrieveRideRequestInfo(getRideRequestId(message), context);
},
onLaunch: (Map<String, dynamic> message) async {
retrieveRideRequestInfo(getRideRequestId(message), context);
},
onResume: (Map<String, dynamic> message) async {
retrieveRideRequestInfo(getRideRequestId(message), context);
},
);
}

似乎你正在使用旧方法。这是更新后的版本。参考资料链接

FirebaseMessaging.onMessage.listen((RemoteMessage message) {
RemoteNotification notification = message.notification;
showNotification(notification);});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print("onMessageOpenedApp: $message");});
FirebaseMessaging.onBackgroundMessage((RemoteMessage message) {
print("onBackgroundMessage: $message");});

相关内容

  • 没有找到相关文章

最新更新