SyncClient

suspend fun SyncClient(context: <Error class: unknown class>, useLastUserAccount: Boolean = true, config: <Error class: unknown class> = SyncConfig(), tokenProvider: suspend () -> String): SyncClient

Creates a new Sync client instance.

Return

New SyncClient instance.

Parameters

context

The Application Context from your Android application.

useLastUserAccount

Try to use offline cache for last logged in user.

Set this parameter to false when you are not sure that current token is for the same AccountDescriptor which was logged in last time, otherwise created client will be shut down once token will be verified after setup network connection.

When this parameter is set to true and offline cache from last session is present (See SyncConfig.cacheConfig usePersistentCache parameter) - client will be returned immediately (even if device is offline). In this case the client will return cached data and start deliver updates when come online.

When this parameter is set to false client will be returned only after connection to backend is established and access to persistent cache will be granted after user's token gets validated by backend. So when cache contains sensitive user data or there are other critical security concerns - always set this parameter to false.

config

Configuration parameters for SyncClient instance.

tokenProvider

Access token provider for Sync service. This provider will be called multiple time: first before creating the client and later each time when token is about to expire.

Throws

TwilioException

When error occurred while client creation.