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.

    Declaration

    Swift

    public weak var delegate: SinchCallClientDelegate? { get set }
  • Make a call to the user with the given id.

    Declaration

    Swift

    public func callUser(withId userId: String) -> Result<SinchCall, Error>

    Parameters

    userId

    The application specific id of the user to call.

    Return Value

    Outgoing call. Instance of SinchCall

  • 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

    userId

    The application specific id of the user to call.

    headers

    String 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

    Declaration

    Swift

    public func videoCallToUser(withId userId: String) -> Result<SinchCall, Error>

    Parameters

    userId

    The application specific id of the user to call.

    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

    userId

    The application specific id of the user to call.

    headers

    String 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

    number

    The 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

    number

    The 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.

    headers

    String 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.

    Declaration

    Swift

    public func callSIP(_ sipIdentity: String) -> Result<SinchCall, Error>

    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

    sipIdentity

    The SIP identity string of the user to call, should be in the form of “user@domain”.

    headers

    String 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

    conferenceId

    The 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

    conferenceId

    The application specific id of the conference to call. It must not exceed 64 characters, or the call will fail immediately.

    headers

    String 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 didActivateAudioSession callback from CXProviderDelegate. 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

    provider

    CXProvider

    audioSession

    The audioSession from the didActivateAudioSession callback of CXProviderDelegate.

  • Notify the Sinch SDK that the app’s audio session was activated.

    Call this in either:

    • ConversationManagerDelegate’s conversationManager(_:didActivate:) (LiveCommunicationKit)
    • CXProviderDelegate’s provider(_: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

    audioSession

    The AVAudioSession instance 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 didDeactivateAudioSession callback from CXProviderDelegate. 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

    provider

    CXProvider

    audioSession

    The audioSession from the didActivateAudioSession callback of CXProviderDelegate.

  • Notify the Sinch SDK that the app’s audio session was deactivated.

    Call this in either:

    • ConversationManagerDelegate’s conversationManager(_:didDeactivate:) (LiveCommunicationKit)
    • CXProviderDelegate’s provider(_: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

    audioSession

    The AVAudioSession instance 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

    webRtcConfiguration

    The configuration to be used for WebRTC calls.