User Token Store
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:
Persist upvote state across app launches (FeedbackClient.toggleVote)
Identify and highlight feature requests created by the user (FeedbackClient.submitFeatureRequest, FeatureRequestItem.isOwnRequest)
Authorize anonymous comments and subscription actions without requiring third-party authentication
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
SharedPreferences instance where the token key is stored.