In my Flutter app, I'm trying to display a full screen Kotlin/Java activity when a FCM message is received in the background using a method channel. I've also tried to use plugins (flutter_local_notifications and CallKeep and GetX) but everytime my onBackgroundMessage is fired, I get a MissingPluginException.
FYI, I also register my plugins in my kotlin application:
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this)
}
override fun registerWith(registry: PluginRegistry?)
{
if (!registry!!.hasPlugin("com.rmawatson.flutterisolate.FlutterIsolatePlugin"))
{
FlutterIsolatePlugin.registerWith(registry?.registrarFor("com.rmawatson.flutterisolate.FlutterIsolatePlugin")
}
if (!registry!!.hasPlugin("co.doneservices.callkeep.CallKeepPlugin"))
{
CallKeepPlugin.registerWith(registry?.registrarFor("co.doneservices.callkeep.CallKeepPlugin"))
}
if (!registry!!.hasPlugin("io.flutter.plugins.firebasemessaging"))
{
FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
}
And here is my Flutter code:
void callReceive(bool show) async {
if (show == true) {
_channelCallReceive.invokeMethod('display');
isolateCallReceive.kill();
}
}
Future<Map<String, dynamic>> myBackgroundMessageHandler(Map<String, dynamic> message) async
{
isolateCallReceive = await FlutterIsolate.spawn(callReceive, true);
}
I've looked at many other solutions on SO but nothing worked for me. I've wasted A LOT of time on this.
The bottom line is... How can I display a full screen notification over the lock screen (or when the flutter app is in the background)?