From 3679c350da832b2e1a9611a0000e26a87cddf728 Mon Sep 17 00:00:00 2001 From: Edwin Nyawoli Date: Fri, 24 Jun 2022 16:28:37 +0000 Subject: [PATCH 1/2] MethodChannel does not support custom type Data --- .../flutter_callkit_incoming/FlutterCallkitIncomingPlugin.kt | 2 +- .../hiennv/flutter_callkit_incoming/SharedPreferencesUtils.kt | 4 ++++ lib/flutter_callkit_incoming.dart | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/FlutterCallkitIncomingPlugin.kt b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/FlutterCallkitIncomingPlugin.kt index 43a94215..dbd0d4d9 100644 --- a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/FlutterCallkitIncomingPlugin.kt +++ b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/FlutterCallkitIncomingPlugin.kt @@ -187,7 +187,7 @@ class FlutterCallkitIncomingPlugin : FlutterPlugin, MethodCallHandler, ActivityA result.success("OK") } "activeCalls" -> { - result.success(getDataActiveCalls(context)) + result.success(getDataActiveCallsForFlutter(context)) } "getDevicePushTokenVoIP" -> { result.success("") diff --git a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/SharedPreferencesUtils.kt b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/SharedPreferencesUtils.kt index a0d8a67f..5c80a4b8 100644 --- a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/SharedPreferencesUtils.kt +++ b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/SharedPreferencesUtils.kt @@ -54,6 +54,10 @@ fun getDataActiveCalls(context: Context?): ArrayList { .fromJson(json, object : TypeToken>() {}.type) } +fun getDataActiveCallsForFlutter(context: Context?): ArrayList> { + val json = getString(context, "ACTIVE_CALLS", "[]") + return Utils.getGsonInstance().fromJson(json, object: TypeToken>>() {}.type) +} fun putString(context: Context?, key: String, value: String?) { if (context == null) return diff --git a/lib/flutter_callkit_incoming.dart b/lib/flutter_callkit_incoming.dart index a12bb186..0a238b36 100644 --- a/lib/flutter_callkit_incoming.dart +++ b/lib/flutter_callkit_incoming.dart @@ -68,7 +68,7 @@ class FlutterCallkitIncoming { /// Get active calls. /// On iOS: return active calls from Callkit. /// On Android: only return last call - static Future activeCalls() async { + static Future> activeCalls() async { return await _channel.invokeMethod("activeCalls"); } From 69acb3839f811c7366914f2763e0265ce3f5e82d Mon Sep 17 00:00:00 2001 From: Edwin Nyawoli Date: Tue, 28 Jun 2022 13:28:24 +0000 Subject: [PATCH 2/2] [Temp] iOS does not always return a list --- lib/flutter_callkit_incoming.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/flutter_callkit_incoming.dart b/lib/flutter_callkit_incoming.dart index 0a238b36..af7cd6b6 100644 --- a/lib/flutter_callkit_incoming.dart +++ b/lib/flutter_callkit_incoming.dart @@ -68,7 +68,7 @@ class FlutterCallkitIncoming { /// Get active calls. /// On iOS: return active calls from Callkit. /// On Android: only return last call - static Future> activeCalls() async { + static Future activeCalls() async { return await _channel.invokeMethod("activeCalls"); }