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.Throws
URLError.badServerResponse
if the URL Loading system received bad data from the server.Throws
NSError
object that indicates why the request failedDeclaration
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
-
getChannelConfiguration(chatURL:
AsynchronousbrandId: channelId: ) 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.Throws
URLError.badServerResponse
if the URL Loading system received bad data from the server.Throws
NSError
object that indicates why the request failedDeclaration
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
-
prepare(environment:
AsynchronousbrandId: channelId: ) 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 stateThrows
missingParameter(_:)
if connectionurl
is not in correct format.Throws
channelConfigFailure
if the SDK could not prepare URL for URLRequestThrows
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 failedThrows
EncodingError.invalidValue
if a non-conforming floating-point value is encountered during encoding, and the encoding strategy is.throw
.Throws
An error if any value throws an error during encoding.
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.
-
prepare(chatURL:
AsynchronoussocketURL: brandId: channelId: ) 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 stateThrows
missingParameter(_:)
if connectionurl
is not in correct format.Throws
channelConfigFailure
if the SDK could not prepare URL for URLRequestThrows
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 failedThrows
EncodingError.invalidValue
if a non-conforming floating-point value is encountered during encoding, and the encoding strategy is.throw
.Throws
An error if any value throws an error during encoding.
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()
AsynchronousConnects 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:)
orprepare(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 stateThrows
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
invalidData
when the Data object cannot be successfully converted to a valid UTF-8 stringThrows
invalidParameter(_:)
if the socket endpoint URL has not been set properlyThrows
channelConfigFailure
if the SDK could not prepare URL for URLRequestThrows
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 failedDeclaration
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 stateDeclaration
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
illegalChatState
if it was unable to trigger the required method because the SDK is not in the required stateThrows
notConnected
if an attempt was made to use a method without connecting first. Make sure you call theconnect
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
invalidData
when the Data object cannot be successfully converted to a valid UTF-8 stringThrows
EncodingError.invalidValue(_:_:)
if the given value is invalid in the current context for this format.Throws
An error if any value throws an error during encoding.
Declaration
Swift
func executeTrigger(_ triggerId: UUID) throws
Parameters
triggerId
The id of the trigger to manually execute.