From fc7b48000924fea674d4332ddf5f7fe1cb8c6d81 Mon Sep 17 00:00:00 2001 From: ppsaww Date: Wed, 12 Jul 2023 16:44:23 +0700 Subject: [PATCH 1/3] add `isMuted` for check CallKit mic status on iOS --- ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift | 13 +++++++++++++ lib/flutter_callkit_incoming.dart | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift index b0778346..f744cf34 100644 --- a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift +++ b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift @@ -132,6 +132,19 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi self.muteCall(callId, isMuted: isMuted) result("OK") break + case "isMuted": + guard let args = call.arguments as? [String: Any] , + let callId = args["id"] as? String else{ + result("OK") + return + } + guard let callUUID = UUID(uuidString: callId), + let call = self.callManager.callWithUUID(uuid: callUUID) else { + result("OK") + return + } + result(call.isMuted) + break case "holdCall": guard let args = call.arguments as? [String: Any] , let callId = args["id"] as? String, diff --git a/lib/flutter_callkit_incoming.dart b/lib/flutter_callkit_incoming.dart index 00daa831..49346d3b 100644 --- a/lib/flutter_callkit_incoming.dart +++ b/lib/flutter_callkit_incoming.dart @@ -63,6 +63,13 @@ class FlutterCallkitIncoming { await _channel.invokeMethod("muteCall", {'id': id, 'isMuted': isMuted}); } + /// Get Callkit Mic Status (muted/unmuted). + /// On iOS, using Callkit(update call ui). + /// On Android, Nothing(only callback event listener). + static Future isMuted(String id) async { + return await _channel.invokeMethod("isMuted", {'id': id}) as bool? ?? false; + } + /// Hold an Ongoing call. /// On iOS, using Callkit(update the ongoing call ui). /// On Android, Nothing(only callback event listener). From e67fee3dc424ede109665aca2ae9eced60544e12 Mon Sep 17 00:00:00 2001 From: Posawat Jirawutworanat Date: Thu, 13 Jul 2023 15:08:41 +0700 Subject: [PATCH 2/3] fix isMuted function cast type error --- 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 49346d3b..af4a8af5 100644 --- a/lib/flutter_callkit_incoming.dart +++ b/lib/flutter_callkit_incoming.dart @@ -67,7 +67,7 @@ class FlutterCallkitIncoming { /// On iOS, using Callkit(update call ui). /// On Android, Nothing(only callback event listener). static Future isMuted(String id) async { - return await _channel.invokeMethod("isMuted", {'id': id}) as bool? ?? false; + return (await _channel.invokeMethod("isMuted", {'id': id})) as bool? ?? false; } /// Hold an Ongoing call. From 95e1accf335471efb17faa5037038bb05b09bcdc Mon Sep 17 00:00:00 2001 From: Posawat Jirawutworanat Date: Thu, 13 Jul 2023 18:18:53 +0700 Subject: [PATCH 3/3] fix return result from isMuted --- ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift index f744cf34..5c45ba69 100644 --- a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift +++ b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift @@ -135,12 +135,12 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi case "isMuted": guard let args = call.arguments as? [String: Any] , let callId = args["id"] as? String else{ - result("OK") + result(false) return } guard let callUUID = UUID(uuidString: callId), let call = self.callManager.callWithUUID(uuid: callUUID) else { - result("OK") + result(false) return } result(call.isMuted)