Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingPluginException when calling external plugin via firebase_messaging onBackgroundMessage #3029

Closed
joshuakoh1 opened this issue Jul 25, 2020 · 1 comment · Fixed by #4012

Comments

@joshuakoh1
Copy link

I'm trying to call a function from within firebase_messaging's onBackgroundMessage. The function works when called from the function registered to onMessage but throws plugin error from the function registered to onBackgroundMessage.

void sendTargetSMS(TargetSMS sms) async {
  SmsSender sender = new SmsSender();
  try {
    SimCardsProvider provider = new SimCardsProvider();
    List<SimCard> cards = await provider.getSimCards();
    ...
  } catch (error) {
    print(error.toString());
  }
}

This works with no errors when called from the onMessage function that is within the MyApp function

  Future notificationOnMessage(Map<String, dynamic> message) async {
    print('OnMessage');
    ...
    try {
      sendTargetSMS(sms);
    } catch (e) {
      print(e);
    }
  }

But when calling this same function from onBackgroundMessage function which exists outside of the main MyApp function

Future notificationOnBackground(Map<String, dynamic> message) async {
  print('OnBackground');
  ...
  try {
    sendTargetSMS(sms);
  } catch (e) {
    print(e);
  }
}

I get missing plugin exception

MissingPluginException(No implementation found for method getSimCards on channel plugins.babariviere.com/simCards)

Both of them are init via configureFirebase

  void configureFirebase(FirebaseMessaging _firebaseMessaging) {
    try {
      _firebaseMessaging.configure(
        onMessage: notificationOnMessage,
        onLaunch: notificationOnLaunch,
        onResume: notificationOnResume,
        onBackgroundMessage: notificationOnBackground,
      );
    } catch (e) {
      print('Error Config Firebase');
      print(e);
    }
  }
@darshankawar
Copy link

Hi @joshuakoh1,
This seems to be an issue with the 3rd party plugin you are using flutter_sms.
Please consider opening this issue against their repo https://github.com/babariviere/flutter_sms.
Closing this since it doesn't seem to be an issue with firebase_messaging.
If you disagree, write in comments and I'll reopen.
Thanks.

@firebase firebase locked and limited conversation to collaborators Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants