Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.3.1

* Fix: [iOS] Fix `hangUp()` not ending incoming call when call is ringing. [Issue #244](https://github.com/cybex-dev/twilio_voice/issues/244)
* Feat: [iOS] Add missing `answer()` native implementation. [Issue #244](https://github.com/cybex-dev/twilio_voice/issues/244)
* Feat: Add raw `Connect({Map<String, dynamic>?})` for all platforms
* Refactor: [Web] Removed unused `web_callkit` event listeners.
* Fix: [Web] Check if call SID is present when call is disconnected (this occurs if the call ends abruptly after starting, and `params` does not contain `CallSid`).
Expand Down
23 changes: 22 additions & 1 deletion ios/Classes/SwiftTwilioVoicePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,14 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
eventSink(!isOnHold ? "Hold" : "Unhold")
}
else if flutterCall.method == "answer" {
// nuthin
if(self.callInvite != nil) {
let ci = self.callInvite!
self.sendPhoneCallEvents(description: "LOG|answer method invoked", isError: false)
self.answerCall(callInvite: ci)
} else {
let ferror: FlutterError = FlutterError(code: "ANSWER_ERROR", message: "No call invite to answer", details: nil)
_result!(ferror)
}
}
else if flutterCall.method == "unregister" {
guard let deviceToken = deviceToken else {
Expand All @@ -287,6 +294,8 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
self.userInitiatedDisconnect = true
performEndCallAction(uuid: self.call!.uuid!)
//self.toggleUIState(isEnabled: false, showCallControl: false)
} else if(self.callInvite != nil) {
performEndCallAction(uuid: self.callInvite!.uuid)
}
}else if flutterCall.method == "registerClient"{
guard let clientId = arguments["id"] as? String, let clientName = arguments["name"] as? String else {return}
Expand Down Expand Up @@ -368,6 +377,18 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand

return false;
}

func answerCall(callInvite: CallInvite) {
let answerCallAction = CXAnswerCallAction(call: callInvite.uuid)
let transaction = CXTransaction(action: answerCallAction)

callKitCallController.request(transaction) { error in
if let error = error {
self.sendPhoneCallEvents(description: "LOG|AnswerCallAction transaction request failed: \(error.localizedDescription)", isError: false)
return
}
}
}

func makeCall(to: String)
{
Expand Down