Skip to content

Instantly share code, notes, and snippets.

@Ayush783
Last active March 7, 2024 11:40
Show Gist options
  • Save Ayush783/4ced79c50d1fe83fc0b9072326044ae0 to your computer and use it in GitHub Desktop.
Save Ayush783/4ced79c50d1fe83fc0b9072326044ae0 to your computer and use it in GitHub Desktop.
Intercept the call accepted action intent from flutter_callkit_incoming when app is launched and passing it to flutter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
channel = MethodChannel(flutterEngine?.dartExecutor?.binaryMessenger!!, "YOUR_CHANNEL_NAME")
val appOpenedIntent = intent
if (
appOpenedIntent != null &&
appOpenedIntent.action == "com.hiennv.flutter_callkit_incoming.ACTION_CALL_ACCEPT"
) {
val extras = appOpenedIntent.extras
if (extras != null) {
Log.d("YOUR_CHANNEL_NAME", fromBundle((extras)).toString())
channel!!.invokeMethod("CALL_ACCEPTED_INTENT", fromBundle(extras))
}
} else {
channel!!.invokeMethod("CHAT_ACCEPTED_INTENT", null)
}
}
private fun fromBundle(bundle: Bundle): HashMap<String, Any?> {
var data: HashMap<String, Any?> = HashMap()
val extra_callkit_data = bundle.getBundle("EXTRA_CALLKIT_CALL_DATA") ?: return data
data =
extra_callkit_data.getSerializable(CallkitConstants.EXTRA_CALLKIT_EXTRA)
as HashMap<String, Any?>
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment