diff --git a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift index 5c45ba69..d52c41ef 100644 --- a/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift +++ b/ios/Classes/SwiftFlutterCallkitIncomingPlugin.swift @@ -36,6 +36,8 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi private var data: Data? private var isFromPushKit: Bool = false private let devicePushTokenVoIP = "DevicePushTokenVoIP" + + private var answerAction: CXAnswerCallAction? private func sendEvent(_ event: String, _ body: [String : Any?]?) { streamHandlers.reap().forEach { handler in @@ -180,6 +182,10 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi case "getDevicePushTokenVoIP": result(self.getDevicePushTokenVoIP()) break; + case "startCallIncoming": + self.answerAction?.fulfill() + result("OK") + break default: result(FlutterMethodNotImplemented) } @@ -485,8 +491,8 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi self?.sharedProvider?.reportOutgoingCall(with: call.uuid, connectedAt: call.connectedData) } self.answerCall = call + self.answerAction = action sendEvent(SwiftFlutterCallkitIncomingPlugin.ACTION_CALL_ACCEPT, self.data?.toJSON()) - action.fulfill() } @@ -508,7 +514,7 @@ public class SwiftFlutterCallkitIncomingPlugin: NSObject, FlutterPlugin, CXProvi action.fulfill() } }else { - sendEvent(SwiftFlutterCallkitIncomingPlugin.ACTION_CALL_ENDED, self.data?.toJSON()) + sendEvent(SwiftFlutterCallkitIncomingPlugin.ACTION_CALL_ENDED, call.data.toJSON()) action.fulfill() } } diff --git a/lib/flutter_callkit_incoming.dart b/lib/flutter_callkit_incoming.dart index bd7625c3..a58d40c3 100644 --- a/lib/flutter_callkit_incoming.dart +++ b/lib/flutter_callkit_incoming.dart @@ -111,6 +111,14 @@ class FlutterCallkitIncoming { return await _channel.invokeMethod("getDevicePushTokenVoIP"); } + + /// Start incoming call + /// On iOS: start connection timer + /// On Android: not implemented + static Future startIncomingCall() async { + await _channel.invokeMethod("startCallIncoming"); + } + /// Request permisstion show notification for Android(13) /// Only Android: show request permission post notification for Android 13+ static Future requestNotificationPermission(dynamic data) async {