3

I'm using firebase and shared_preference in my flutter project, where I need to store a incoming message to the shared preferences. Whenever a message is received, I am getting the below exception

I/flutter (29300): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter (29300): MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

I know that _firebaseMessagingBackgroundHandler will spawn a new isolate, but does that make other plugins unaccessible?? This is my handler

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  final prefs = await SharedPreferences.getInstance();
  await prefs.reload();
  await prefs.setStringList(
      DateTime.now().toIso8601String().substring(0, 19) + ".000000", [message.notification!.body.toString(), message.notification!.title.toString()]);
}

I have also confirmed that shared preferences present in generated_plugin_registrant.dart. I have used FlutterFire CLI for integerating firebase with my app.

  • Do a flutter clean and flutter pub get. After adding any plugin new in pubspec.yaml file. you need to do flutter packages get command. Stopping running app, uninstalling then rebuild. – Meet Prajapati Mar 11 '22 at 02:53
  • @MeetPrajapati , Thanks Prajapati, I have tried those, but didn't work for me. Also please know that I have used the flutter-fire cli for firebase integeration, if its helpful. – Vetrivelu Murugesan Mar 11 '22 at 14:13
  • Any solution for this? Maybe generated_plugin_registrant not generated for seperate isolate like FirebaseMessaging.onBackgroundMessage(h); . Because all third party dependencies aren't available for it. – MerdanDev Apr 20 '22 at 15:39
  • @VetriveluMurugesan have you found any solution? facing the same issue tried flutter clean, pub get, package upgrade nothing works. – RAMU PAL May 27 '22 at 14:36
  • @RAMUPAL No, I haven't found any... – Vetrivelu Murugesan May 29 '22 at 20:05

0 Answers0