1 year ago

#276839

test-img

Vetrivelu Murugesan

FlutterFire Messaging : MissingPluginException error thrown for Shared Preferences

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.

flutter

firebase-cloud-messaging

sharedpreferences

dart-isolates

0 Answers

Your Answer

Accepted video resources