@@ -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 {
@@ -287,6 +294,8 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
287294 self . userInitiatedDisconnect = true
288295 performEndCallAction ( uuid: self . call!. uuid!)
289296 //self.toggleUIState(isEnabled: false, showCallControl: false)
297+ } else if ( self . callInvite != nil ) {
298+ performEndCallAction ( uuid: self . callInvite!. uuid)
290299 }
291300 } else if flutterCall. method == " registerClient " {
292301 guard let clientId = arguments [ " id " ] as? String , let clientName = arguments [ " name " ] as? String else { return }
@@ -368,6 +377,18 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
368377
369378 return false ;
370379 }
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+ }
371392
372393 func makeCall( to: String )
373394 {
0 commit comments