Describe the bug
When upgrading from version 6.0.3 of firebase_messaging our onBackgroundMessage handler is no longer called. Instead the following error is printed to the Android log:
I/flutter (20210): Unable to handle incoming background message.
I/flutter (20210): NoSuchMethodError: The method 'call' was called on null.
I/flutter (20210): Receiver: null
I/flutter (20210): Tried calling: call(_LinkedHashMap len:1)
This occurs even if my handler is just a simple print statement, thus the null.call(...) doesn't happen in my handler.
Here is where the error is logged from:
To Reproduce
Steps to reproduce the behavior:
firebase_messaging version 6.0.3firebase_messaging versionExpected behavior
The message should be received with both versions.
Additional context
n/a
Hi @LinusU
can you please provide your flutter doctor -v,
your pubspec.yaml
and your flutter run --verbose?
Thank you
From a discussion in our team chat: this is likely caused by a bug in how we added Android v2 embedding support. See also flutter/flutter#47406, which is showing similar symptoms when running in the background because of a change in the v2 embedding.
/cc @bparrishMines
Hi @mklim any update for this issue? cause i can't see notification in background untill now.
@LinusU do you have a solution? i need your help for this issue
I am also faced this issue after upgrade .. Please register the plugin like below in Application class for android. Now it's working for me
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this)
}
override fun registerWith(registry: PluginRegistry) {io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")); io.flutter.plugins.pathprovider.PathProviderPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin")); com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.registerWith(registry?.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
}
}
Any solutions?
Also can you please expound on the background handler? How are you logging a backgrounded application?
Note that the comments in this thread shows two different things, one is a user error, the other is a bug:
DATA='{"data": {"click_action": "FLUTTER_NOTIFICATION_CLICK", "id": "1", "status": "done"}, "to": "<token>"}'), you will be able to send a message that is received, however...(edited) => after some more testing, I can confirm that I only see the bug when the message is formatted as in item 1 above. The reason is that with the absence of a notification item in the message, the message will be attempted sent to the background handler. However, WITH the notification item present, the default android message handler will present a regular android tray notification. When the user selects the notification, your app will be resume and the onResume function called as expected. This is probably what most app developers want as you can then react to the message with UI updates as well. However, if you want to silently trigger a background action without any user interaction, you are still hit by this bug.
Hey all 馃憢
As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues.
If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.
Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.
Thanks everyone.
Most helpful comment
Hi @mklim any update for this issue? cause i can't see notification in background untill now.
@LinusU do you have a solution? i need your help for this issue