Open redevrx opened 5 months ago
@redevrx
hi, no idea if your issue still persist but i had the same problem and after hours of trying to solve it, chatgpt helped me 😆
add this function to your class (notification extension, right?)
import java.nio.ByteBuffer
private fun initializeFlutterCallkitIncomingPlugin(context: Context) {
if (!FlutterCallkitIncomingPlugin.hasInstance()) {
val binaryMessenger = object : BinaryMessenger {
override fun send(channel: String, message: ByteBuffer?) {
// No-op
}
override fun send(channel: String, message: ByteBuffer?, callback: BinaryMessenger.BinaryReply?) {
// No-op
}
override fun setMessageHandler(channel: String, handler: BinaryMessenger.BinaryMessageHandler?) {
// No-op
}
}
FlutterCallkitIncomingPlugin.initSharedInstance(context, binaryMessenger)
}
}
and call before you call into the plugin:
initializeFlutterCallkitIncomingPlugin(context)
that solved my problem and all calls are properly coming in even if app is killed, background etc!
@hiennguyen92 you might wanna take a look at this as currently the plugin cannot be called when the app is killed (terminated state).
Obviously my snippet is a workaround but if you have any idea how to implement this properly that would be great!
Hello, I have resolved this issue by using a Flutter loader. When the Flutter initialization is successful, I will call incoming.
@redevrx ah so you are not calling from notification extension? When the app is terminated there is no flutter instance anywhere so I cannot init flutter yet. it's being initialized after the user accepts the call and the app opens.
I receive notifications from native and open incoming notifications. As for starting the Flutter engine, we can cache the engine by checking if there is a cache. If not, we create a new engine. If you don't do this, the accept call button won't work if pressed when the app is closed.
then maybe our use case is different. for me it's a video call so the app starts automatically when the user accepts the call so it's not a normal "call only" UI, that might be the difference here.
How to create instance FlutterCallkitIncomingPlugin in native background service