|
|
|
@ -23,33 +23,30 @@ import Foundation
|
|
|
|
|
/**
|
|
|
|
|
* |handle| is a user formatted phone number, e.g. from a system contacts entry
|
|
|
|
|
*/
|
|
|
|
|
public func initiateCall(handle: String) {
|
|
|
|
|
public func initiateCall(handle: String) -> Bool {
|
|
|
|
|
Logger.info("\(TAG) in \(#function) with handle: \(handle)")
|
|
|
|
|
|
|
|
|
|
guard let recipientId = PhoneNumber(fromUserSpecifiedText: handle)?.toE164() else {
|
|
|
|
|
Logger.warn("\(TAG) unable to parse signalId from phone number: \(handle)")
|
|
|
|
|
return
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initiateCall(recipientId: recipientId)
|
|
|
|
|
return initiateCall(recipientId: recipientId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* |recipientId| is a e164 formatted phone number.
|
|
|
|
|
*/
|
|
|
|
|
public func initiateCall(recipientId: String) {
|
|
|
|
|
self.initiateWebRTCAudioCall(recipientId: recipientId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func initiateWebRTCAudioCall(recipientId: String) {
|
|
|
|
|
// Rather than an init-assigned dependency property, we access `callUIAdapter` via Environment
|
|
|
|
|
public func initiateCall(recipientId: String) -> Bool {
|
|
|
|
|
// Rather than an init-assigned dependency property, we access `callUIAdapter` via Environment
|
|
|
|
|
// because it can change after app launch due to user settings
|
|
|
|
|
guard let callUIAdapter = Environment.getCurrent().callUIAdapter else {
|
|
|
|
|
assertionFailure()
|
|
|
|
|
Logger.error("\(TAG) can't initiate call because callUIAdapter is nil")
|
|
|
|
|
return
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callUIAdapter.startAndShowOutgoingCall(recipientId: recipientId)
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|