Skip to content

Commit 499a29e

Browse files
committed
feat(ios): fix no impl for call answer()
1 parent 15c848e commit 499a29e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

ios/Classes/SwiftTwilioVoicePlugin.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,14 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
268268
eventSink(!isOnHold ? "Hold" : "Unhold")
269269
}
270270
else if flutterCall.method == "answer" {
271-
// nuthin
271+
if(self.callInvite != nil) {
272+
let ci = self.callInvite!
273+
self.sendPhoneCallEvents(description: "LOG|answer method invoked", isError: false)
274+
self.answerCall(callInvite: ci)
275+
} else {
276+
let ferror: FlutterError = FlutterError(code: "ANSWER_ERROR", message: "No call invite to answer", details: nil)
277+
_result!(ferror)
278+
}
272279
}
273280
else if flutterCall.method == "unregister" {
274281
guard let deviceToken = deviceToken else {
@@ -370,6 +377,18 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
370377

371378
return false;
372379
}
380+
381+
func answerCall(callInvite: CallInvite) {
382+
let answerCallAction = CXAnswerCallAction(call: callInvite.uuid)
383+
let transaction = CXTransaction(action: answerCallAction)
384+
385+
callKitCallController.request(transaction) { error in
386+
if let error = error {
387+
self.sendPhoneCallEvents(description: "LOG|AnswerCallAction transaction request failed: \(error.localizedDescription)", isError: false)
388+
return
389+
}
390+
}
391+
}
373392

374393
func makeCall(to: String)
375394
{

0 commit comments

Comments
 (0)