Move outgoing call intelligence to CallKit delegate

This commit is contained in:
QuentinArguillere
2020-08-10 18:12:00 +02:00
parent 6704c0fdcb
commit 375337498b
2 changed files with 12 additions and 16 deletions

View File

@@ -115,16 +115,7 @@ class CallExampleContext : ObservableObject
do {
if (!callRunning)
{
let callDest = try Factory.Instance.createAddress(addr: dest)
// Place an outgoing call
mCall = mCore.inviteAddressWithParams(addr: callDest, params: try createCallParams())
if (mCall == nil) {
print("Could not place call to \(dest)\n")
} else {
print("Call to \(dest) is in progress...")
mProviderDelegate.outgoingCallUUID = UUID()
}
mProviderDelegate.outgoingCall()
}
else
{
@@ -152,10 +143,7 @@ class CallExampleContext : ObservableObject
{
speakerEnabled = !speakerEnabled
do {
try AVAudioSession.sharedInstance().overrideOutputAudioPort(
speakerEnabled ?
AVAudioSession.PortOverride.speaker : AVAudioSession.PortOverride.none
)
try AVAudioSession.sharedInstance().overrideOutputAudioPort(speakerEnabled ? AVAudioSession.PortOverride.speaker : AVAudioSession.PortOverride.none )
} catch {
print(error)
}

View File

@@ -46,7 +46,7 @@ class CallKitProviderDelegate : NSObject
let startCallAction = CXStartCallAction(call: outgoingCallUUID, handle: handle)
let transaction = CXTransaction(action: startCallAction)
provider.reportOutgoingCall(with: outgoingCallUUID, connectedAt: nil)
provider.reportOutgoingCall(with: outgoingCallUUID, startedConnectingAt: nil)
mCallController.request(transaction, completion: { error in })
}
@@ -94,7 +94,15 @@ extension CallKitProviderDelegate: CXProviderDelegate {
}
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
tutorialContext.outgoingCallExample()
do {
let callDest = try Factory.Instance.createAddress(addr: tutorialContext.dest)
// Place an outgoing call
tutorialContext.mCall = tutorialContext.mCore.inviteAddressWithParams(addr: callDest, params: try tutorialContext.createCallParams())
} catch {
print(error)
}
action.fulfill()
}