Move outgoing call intelligence to CallKit delegate
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user