0

I have been using Firebase Messaging in my app for a couple of years but after I decided to update my app and updated Flutter and plugin versions my existing code stopped working. I checked the official documentations but couldn't find an answer to why this code is not working. The code I use is below. What has changed in the new version causing my code to cease working?

 @override void initState() { super.initState(); _firebaseMessaging.configure( onMessage: (Map<String, dynamic> message) async { print("onMessage: $message"); }, onLaunch: (Map<String, dynamic> message) async { print("onLaunch: $message"); }, onResume: (Map<String, dynamic> message) async { print("onResume: $message"); }, ); _firebaseMessaging.requestNotificationPermissions( const IosNotificationSettings(sound: true, badge: true, alert: true)); _firebaseMessaging.onIosSettingsRegistered .listen((IosNotificationSettings settings) { print("Settings registered: $settings"); }); _firebaseMessaging.getToken().then((String token) { assert(token != null); setState(() { _homeScreenText = "Push Messaging token: $token"; }); print(_homeScreenText); }); } 

1 Answer 1

1

I think you are using the old method. Here is the new method:

My firebase_messaging package version is 10.0.1.

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"); }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.