UserTokenStore

Persistent anonymous device token store backed by Android SharedPreferences.

Provides a stable, pseudonymous UUID token for the lifetime of an app installation. This token is used across CupThread SDK endpoints to:

Lifecycle and Storage

  • Generates a new random RFC 4122 UUID v4 on first access and immediately persists it into private SharedPreferences.

  • Subsequent reads reuse the cached token, surviving activity recreations, process death, and app updates.

  • The token resets only when the user clears app storage or uninstalls the application.

Recommended Usage

Create a single instance per application process (e.g. via dependency injection or in your Application / ComponentActivity):

class MainActivity : ComponentActivity() {
private val userTokenStore by lazy { UserTokenStore.create(this) }
private val feedbackClient by lazy {
FeedbackClient(FeedbackClientConfig(baseUrl = "https://api.cupthread.com", appKey = "app_live_sample"))
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val token = userTokenStore.token
setContent {
FeatureRequestsScreen(client = feedbackClient, userToken = token)
}
}
}

Parameters

prefs

SharedPreferences instance where the token key is stored.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The stable anonymous user token.