SinchCallClient
public final class SinchCallClient
SinchCallClient provides the entry point to the calling functionality of the Sinch SDK. A SinchCallClient can be acquired via SinchClient.
Example
var sinchClient: SinchClient
sinchClient.start()
...
// Place outgoing call.
let callClient = sinchClient.callClient
let result = callClient.callUser(withId:"<REMOTE USERID>")
switch result {
case let .success(call):
// NOTE: Mediator is the only delegate of the call and will do the fanout of events
call.delegate = self
....
// Hang up the call
call.hangup()
case let .failure(error):
print("Unable to make a call: \(error.localizedDescription)")
}
-
The object that acts as the delegate of the call client.
The delegate object handles call state change events and must adopt the SinchCallClientDelegate protocol.
See also
SinchCallClientDelegateDeclaration
Swift
public weak var delegate: SinchCallClientDelegate? { get set } -
Calls the user with the given id and the given headers.
Declaration
Swift
public func callUser(withId userId: String, usingHeaders headers: [String : Any]) -> Result<SinchCall, Error>Parameters
userIdThe application specific id of the user to call.
headersString key-value pairs to pass with the call. The total size of header keys + values (when encoded with UTF-8) must not exceed 1024 bytes. The call will fail immediately in case of invalid headers.
Return Value
Outgoing call. Instance of
SinchCall -
Make a video call to the user with the given id and the give headers
Declaration
Swift
public func videoCallToUser(withId userId: String, usingHeaders headers: [String : Any]) -> Result<SinchCall, Error>Parameters
userIdThe application specific id of the user to call.
headersString key-value pairs to pass with the call. The total size of header keys + values (when encoded with UTF-8) must not exceed 1024 bytes. The call will fail immediately in case of invalid headers.
Return Value
Outgoing call. Instance of
SinchCall -
Calls a phone number and terminates the call to the PSTN-network (Publicly Switched Telephone Network).
Declaration
Swift
public func callPhoneNumber(_ number: String) -> Result<SinchCall, Error>Parameters
numberThe phone number to call. The phone number should be given according to E.164 number formatting (http://en.wikipedia.org/wiki/E.164) and should be prefixed with a ‘+’. E.g. to call the US phone number 415 555 0101, it should be specified as “+14155550101”, where the ‘+’ is the required prefix and the US country code ‘1’ added before the local subscriber number.
Return Value
Outgoing call. Instance of
SinchCall -
Calls a phone number and terminate the call to the PSTN-network (Publicly Switched Telephone Network).
Declaration
Swift
public func callPhoneNumber(_ number: String, usingHeaders headers: [String : Any]) -> Result<SinchCall, Error>Parameters
numberThe phone number to call. The phone number should be given according to E.164 number formatting (http://en.wikipedia.org/wiki/E.164) and should be prefixed with a ‘+’. E.g. to call the US phone number 415 555 0101, it should be specified as “+14155550101”, where the ‘+’ is the required prefix and the US country code ‘1’ added before the local subscriber number.
headersString key-value pairs to pass with the call. The total size of header keys + values (when encoded with UTF-8) must not exceed 1024 bytes. The call will fail immediately in case of invalid headers.
Return Value
Outgoing call. Instance of
SinchCall -
Make a SIP call to user with the given SIP Identity and adding the given headers.
Declaration
Swift
public func callSIP(_ sipIdentity: String, usingHeaders headers: [String : Any]) -> Result<SinchCall, Error>Parameters
sipIdentityThe SIP identity string of the user to call, should be in the form of “user@domain”.
headersString key-value pairs to pass with the call. The total size of header keys + values (when encoded with UTF-8) must not exceed 1024 bytes. Thd call will fail immediately in case of invalid headers.
Return Value
Outgoing call. Instance of
SinchCall -
Calls the conference with the given id.
Declaration
Swift
public func callConference(withId conferenceId: String) -> Result<SinchCall, Error>Parameters
conferenceIdThe application specific id of the conference to call. It must not exceed 64 characters, or the call will fail immediately.
Return Value
Outgoing call. Instance of
SinchCall -
Calls the conference with the given id and the given headers.
Declaration
Swift
public func callConference(withId conferenceId: String, usingHeaders headers: [String : Any]) -> Result<SinchCall, Error>Parameters
conferenceIdThe application specific id of the conference to call. It must not exceed 64 characters, or the call will fail immediately.
headersString key-value pairs to pass with the call. The total size of header keys + values (when encoded with UTF-8) must not exceed 1024 bytes. In case of invalid headers, the call will fail immediately.
Return Value
Outgoing call. Instance of
SinchCall -
This API is introduced to support CallKit integration. Invoke this method to notify the Sinch SDK that the App has received the
didActivateAudioSessioncallback fromCXProviderDelegate. When CallKit is integrated in the App and an incoming call is received in the background, this method has to be invoked for the Sinch SDK to start the media for the call.Declaration
Swift
@available(*, deprecated, message: "Use didActivate(audioSession:﹚ instead") public func provider(provider: CXProvider, didActivateAudioSession audioSession: AVAudioSession)Parameters
providerCXProvider
audioSessionThe audioSession from the didActivateAudioSession callback of CXProviderDelegate.
-
Notify the Sinch SDK that the app’s audio session was activated.
Call this in either:
ConversationManagerDelegate’sconversationManager(_:didActivate:)(LiveCommunicationKit)CXProviderDelegate’sprovider(_:didActivate:)(CallKit)
When LiveCommunicationKit or CallKit is integrated in the app and an incoming call is received while the app is backgrounded, this method must be called for the Sinch SDK to start its media (e.g. begin sending/receiving voice data).
Declaration
Swift
public func didActivate(audioSession: AVAudioSession)Parameters
audioSessionThe
AVAudioSessioninstance that has just been activated. -
This API is introduced to support CallKit integration. Invoke this method to notify the Sinch SDK that the App has received the
didDeactivateAudioSessioncallback fromCXProviderDelegate. When CallKit is integrated in the App, this method has to be invoked to pass the didDeactivateAudioSession event from CallKit to the Sinch SDK for correct audio session management.Declaration
Swift
@available(*, deprecated, message: "Use didDeactivate(audioSession:﹚ instead") public func provider(provider: CXProvider, didDeactivateAudioSession audioSession: AVAudioSession)Parameters
providerCXProvider
audioSessionThe audioSession from the didActivateAudioSession callback of CXProviderDelegate.
-
Notify the Sinch SDK that the app’s audio session was deactivated.
Call this in either:
ConversationManagerDelegate’sconversationManager(_:didDeactivate:)(LiveCommunicationKit)CXProviderDelegate’sprovider(_:didDeactivate:)(CallKit)
When LiveCommunicationKit or CallKit is integrated in the app, this method must be called to pass the deactivation event to the Sinch SDK so it can correctly tear down its audio session.
Declaration
Swift
public func didDeactivate(audioSession: AVAudioSession)Parameters
audioSessionThe
AVAudioSessioninstance that has just been deactivated. -
Sets the WebRTC configuration for every call created by SinchCallClient. This method must be invoked before initiating any outgoing call or relying the push payload to ensure the configuration is applied.
Declaration
Swift
public func setWebRtcCallConfiguration(_ webRtcCallConfiguration: SinchWebRtcCallConfiguration)Parameters
webRtcConfigurationThe configuration to be used for WebRTC calls.