ConnectionProvider

public protocol ConnectionProvider

The provider for connection related properties and methods.

  • The current channel configuration for currently connected CXone session.

    Declaration

    Swift

    var channelConfiguration: ChannelConfiguration { get }
  • Makes an HTTP request to get the channel configuration details.

    Throws

    - channelConfigFailure if provided parameters do not create a valid URL.

    Throws

    DecodingError.dataCorrupted an indication that the data is corrupted or otherwise invalid.

    Throws

    DecodingError.typeMismatch if the encountered stored value is not a JSON object or otherwise cannot be converted to the required type.

    Throws

    DecodingError.keyNotFound if the response does not have an entry for the given key.

    Throws

    DecodingError.valueNotFound if a response has a null value for the given key.

    Declaration

    Swift

    func getChannelConfiguration(environment: Environment, brandId: Int, channelId: String) async throws -> ChannelConfiguration

    Parameters

    environment

    The CXone Environment used to connect. Relates to your location.

    brandId

    The unique id of the brand for which to open the connection.

    channelId

    The unique id of the channel for the connection.

    Return Value

    Channel configuration details

  • Makes an HTTP request to get the channel configuration details.

    Throws

    channelConfigFailure if provided parameters do not create a valid URL.

    Throws

    DecodingError.dataCorrupted an indication that the data is corrupted or otherwise invalid.

    Throws

    DecodingError.typeMismatch if the encountered stored value is not a JSON object or otherwise cannot be converted to the required type.

    Throws

    DecodingError.keyNotFound if the response does not have an entry for the given key.

    Throws

    DecodingError.valueNotFound if a response has a null value for the given key.

    Declaration

    Swift

    func getChannelConfiguration(chatURL: String, brandId: Int, channelId: String) async throws -> ChannelConfiguration

    Parameters

    chatURL

    The chat URL for the custom environment.

    brandId

    The unique id of the brand for which to open the connection.

    channelId

    The unique id of the channel for the connection.

    completion

    Completion handler to be called when the request is successful or fails.

    Return Value

    Channel configuration details

  • Prepares the SDK for establishing connection to the CXone service.

    In order to use any AnalyticsProvider methods, you must first call this method.

    Throws

    illegalChatState if it was unable to trigger the required method because the SDK is not in the required state

    Throws

    missingParameter(_:) if connectionurl is not in correct format.

    Throws

    channelConfigFailure if the SDK could not prepare URL for URLRequest.

    Throws

    DecodingError.dataCorrupted an indication that the data is corrupted or otherwise invalid.

    Throws

    DecodingError.typeMismatch if the encountered stored value is not a JSON object or otherwise cannot be converted to the required type.

    Throws

    DecodingError.keyNotFound if the response does not have an entry for the given key.

    Throws

    DecodingError.valueNotFound if a response has a null value for the given key.

    Throws

    URLError.badServerResponse if the URL Loading system received bad data from the server.

    Throws

    NSError object that indicates why the request failed

    Declaration

    Swift

    func prepare(environment: Environment, brandId: Int, channelId: String) async throws

    Parameters

    environment

    The CXone Environment used to connect. Relates to your location.

    brandId

    The unique id of the brand for which to open the connection.

    channelId

    The unique id of the channel for the connection.

  • Prepares the SDK for establishing connection to the CXone service.

    In order to you use any AnalyticsProvider methods, it is necessary to call this method before invoking any of them.

    Throws

    illegalChatState if it was unable to trigger the required method because the SDK is not in the required state

    Throws

    missingParameter(_:) if connectionurl is not in correct format.

    Throws

    channelConfigFailure if the SDK could not prepare URL for URLRequest.

    Throws

    DecodingError.dataCorrupted an indication that the data is corrupted or otherwise invalid.

    Throws

    DecodingError.typeMismatch if the encountered stored value is not a JSON object or otherwise cannot be converted to the required type.

    Throws

    DecodingError.keyNotFound if the response does not have an entry for the given key.

    Throws

    DecodingError.valueNotFound if a response has a null value for the given key.

    Throws

    URLError.badServerResponse if the URL Loading system received bad data from the server.

    Throws

    NSError object that indicates why the request failed

    Declaration

    Swift

    func prepare(chatURL: String, socketURL: String, brandId: Int, channelId: String) async throws

    Parameters

    chatURL

    The URL to be used for chat requests (channel config and attachment upload).

    socketURL

    The URL to be used for the WebSocket connection.

    brandId

    The unique id of the brand for which to open the connection.

    channelId

    The unique id of the channel for the connection.

  • connect() Asynchronous

    Connects to the CXone service via web socket.

    This method establishes web socket connection to be able to receive chat events defined in CXoneChatDelegate.

    Precondition

    Either prepare(environment:brandId:channelId:) or prepare(chatURL:socketURL:brandId:channelId:) method must be called before this method.

    Throws

    illegalChatState if it was unable to trigger the required method because the SDK is not in the required state

    Throws

    webSocketConnectionFailure if the web socket refused to connect.

    Throws

    customerAssociationFailure if the SDK could not get customer identity and it may not have been set.

    Throws

    missingAccessToken if the customer was successfully authorized, but an access token wasn’t returned.

    Throws

    invalidThread if the provided ID for the thread was invalid, so the action could not be performed.

    Throws

    EncodingError.invalidValue(_:_:) if the given value is invalid in the current context for this format.

    Throws

    URLError.badServerResponse if the URL Loading system received bad data from the server.

    Throws

    NSError object that indicates why the request failed

    Declaration

    Swift

    func connect() async throws
  • Disconnects from the CXone service and keeps the customer signed in.

    Declaration

    Swift

    func disconnect()
  • Pings the CXone chat server to ensure that a connection is established.

    Throws

    illegalChatState if it was unable to trigger the required method because the SDK is not in the required state

    Declaration

    Swift

    func ping() throws
  • Manually executes a trigger that was defined in CXone. This can be used to test that proactive actions are displaying.

    Throws

    notConnected if an attempt was made to use a method without connecting first. Make sure you call the connect method first.

    Throws

    customerVisitorAssociationFailure if the customer could not be associated with a visitor.

    Throws

    customerAssociationFailure The SDK instance could not get customer identity possibly because it may not have been set.

    Throws

    EncodingError.invalidValue(_:_:) if the given value is invalid in the current context for this format.

    Declaration

    Swift

    func executeTrigger(_ triggerId: UUID) throws

    Parameters

    triggerId

    The id of the trigger to manually execute.