Closed
Description
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);
}
}
Metadata
Metadata
Assignees
Labels
No labels