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

  • Dials a phone number, placing an audio call routed through the Sinch Voice V2 platform and terminated to the PSTN-network (Publicly Switched Telephone Network).

    Warning

    Beta API. It is functional, but its signature or behaviour may change in a future release without going through the usual deprecation cycle.

    Declaration

    Swift

    public func dialPhoneNumber(_ number: String,
                                options: SinchDialPhoneNumberOptions = SinchDialPhoneNumberOptions())
      -> Result<SinchCall, Error>

    Parameters

    number

    The phone number to dial. 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 dial 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.

    options

    Voice V2 phone dial options. See SinchDialPhoneNumberOptions.

    Return Value

    Outgoing call. Instance of SinchCall

  • Dials a SIP endpoint, placing an audio call routed through the Sinch Voice V2 platform.

    Warning

    Beta API. It is functional, but its signature or behaviour may change in a future release without going through the usual deprecation cycle.

    Declaration

    Swift

    public func dialSip(_ sipUri: String, options: SinchDialSipOptions = SinchDialSipOptions()) -> Result<SinchCall, Error>

    Parameters

    sipUri

    SIP URI of the destination, e.g. “sip:alice@example.com”.

    options

    SIP destination and Voice V2 service options. See SinchDialSipOptions.

    Return Value

    Outgoing call. Instance of SinchCall

  • Dials an audio stream endpoint through the Sinch Voice V2 platform.

    Warning

    Beta API. It is functional, but its signature or behaviour may change in a future release without going through the usual deprecation cycle.

    Declaration

    Swift

    public func dialStream(_ endpoint: String,
                           options: SinchDialStreamOptions = SinchDialStreamOptions()) -> Result<SinchCall, Error>

    Parameters

    endpoint

    Stream endpoint URL, e.g. “wss://example.com/audio”.

    options

    Voice V2 stream destination options. See SinchDialStreamOptions.

    Return Value

    Outgoing call. Instance of SinchCall

  • Dials a Voice Relay WebSocket endpoint through the Sinch Voice V2 platform.

    Warning

    Beta API. It is functional, but its signature or behaviour may change in a future release without going through the usual deprecation cycle.

    Declaration

    Swift

    public func dialVoiceRelay(_ endpoint: String, options: SinchDialVoiceRelayOptions) -> Result<SinchCall, Error>

    Parameters

    endpoint

    WebSocket URL of the Voice Relay server, e.g. “wss://example.com/agent”.

    options

    Voice Relay Voice V2 options, including the required TTS voice and STT language. See SinchDialVoiceRelayOptions and Voice locales for the available voices and locales.

    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.