The method 'configure' isn't defined for the type 'FirebaseMessaging'. Can anyone retype my code correctly? Thanks

231

Seems like you are using the old method. Here is the updated version. Link for your references

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");});
Share:
231
Michelangelo
Author by

Michelangelo

Updated on January 01, 2023

Comments

  • Michelangelo
    Michelangelo over 1 year
    1. Push Notification code. I don't understand how to implement the new method of implementing a notification in flutter using firebase
    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);
          },
        );
      }
    
    • Michelangelo
      Michelangelo over 2 years
      I'm new to flutter dev and i'm currently working on a project