I'm using firebaseMessagingBackgroundHandler
in a Flutter plugin called FCMConfig
.
Previously the following code previously worked.
Future<void> firebaseMessagingBackgroundHandler(
RemoteMessage _notification) async {
print('Handling a background message: ${_notification.data["title"]}');
String fcmname = _notification.data["name"];
String fcmtitle = _notification.data["title"];
String fcmmessage = _notification.data["message"];
String title = _notification.data["title_key"];
FCMConfig.displayNotification(title: fcmtitle, body:fcmname);
}
But after some updates to the 2.1.2 minimum SDK I've started to get this error;
Instance member 'displayNotification' can't be accessed using static access.
How can I fix this?
According to the documentation, you are supposed to do this:
Future<void> firebaseMessagingBackgroundHandler(
RemoteMessage _notification) async {
print('Handling a background message: ${_notification.data["title"]}');
String fcmname = _notification.data["name"];
String fcmtitle = _notification.data["title"];
String fcmmessage = _notification.data["message"];
String title = _notification.data["title_key"];
FCMConfig().displayNotification(title: fcmtitle, body:fcmname); // <---
}
You forgot the parenthesis ().