CustomerProvider
public protocol CustomerProvider : Sendable
The provider for customer related properties and methods.
-
The customer currently using the app.
Declaration
Swift
func get() -> CustomerIdentity?Return Value
Returns customer if it is set. Otherwise; returns
nil. -
Sets the customer currently using the app.
If you set your customer ID, you must ensure that it is unique and that it is not used by any other customer.
Note
Setting your own Customer ID may result in security vulnerabilities. It is recommended to use the customer ID provided by the SDK. If you want to update the customer name, use the
setName(firstName:lastName:)method.Warning
This method must be called before SDK initialization via
prepare(environment:brandId:channelId:).Throws
illegalChatStateif the chat is already initialized.Declaration
Swift
func set(customer: CustomerIdentity?) throwsParameters
customerThe customer identity. Can be
nil. -
Registers a device to be used for push notifications.
Declaration
Swift
func setDeviceToken(_ token: String)Parameters
tokenThe unique token for the device to be registered.
-
Registers a device to be used for push notifications.
Declaration
Swift
func setDeviceToken(_ tokenData: Data)Parameters
tokenDataThe unique token for the device to be registered.
-
Provides a connection token and its expiry to the SDK for the implicit OAuth flow.
Call this before
connect()with the JWT obtained from your OAuth provider, and again whenever the SDK reports the token is no longer valid by throwinginvalidAccessTokenfrom an outbound method — obtain a fresh token, provide it here, and retry the operation that threw.The SDK uses
expiresAtto detect an expired token before sending an event (a backend rejection of an already-open socket is not otherwise observable) and to signal you to refresh in time. The SDK never sources tokens on its own — it always obtains them from the integrator, either via this call or via the listener registered withsetTokenDelegateListener(_:).Declaration
Swift
func setConnectionToken(_ token: String, expiresAt: Date)Parameters
tokenA valid JWT obtained from the OAuth provider.
expiresAtThe absolute time at which
tokenexpires (e.g. derived from the provider’sexpires_in). -
Registers a listener the SDK calls to obtain a fresh connection token for the implicit OAuth flow.
When registered, the SDK requests a fresh token automatically — shortly before the current one expires (
tokenExpired) or after the backend rejects it at connect (tokenInvalid). It pauses the pending operation, obtains the token, and resumes it, so outbound events are not interrupted. Concurrent operations queue behind a single refresh. The listener obtains a token from your OAuth provider and returns anOAuthToken; if it throws, the pending operation fails withinvalidAccessToken.The initial token is still provided via
setConnectionToken(_:expiresAt:); this listener handles subsequent refreshes. When no listener is registered, an expired token surfaces reactively asinvalidAccessTokenfrom the outbound method.Declaration
Swift
func setTokenDelegateListener(_ listener: TokenDelegateListener?)Parameters
listenerThe token listener, or
nilto remove a previously registered one. -
Sets the authorization code for the explicit OAuth flow (PKCE).
Call this before
connect()when using an explicit OAuth flow.Declaration
Swift
func setAuthorizationCode(_ code: String)Parameters
codeThe authorization code received from the OAuth provider.
-
Sets the PKCE code verifier for the explicit OAuth flow.
Call this before
connect()when using an explicit OAuth flow.Declaration
Swift
func setCodeVerifier(_ verifier: String)Parameters
verifierThe PKCE code verifier generated locally before the authorization request.
-
Sets the name to be used for the customer in the chat.
Declaration
Swift
func setName(firstName: String, lastName: String)Parameters
firstNameThe first name for the customer.
lastNameThe last name for the customer.
View on GitHub