IdentifyKit
Manages user authentication state for the Monterosa SDK and bridges it into embedded Experiences.
Obtain an instance via IdentifyKit.default or IdentifyKit.from, set credentials to provide the user's authentication token, then call getSessionSignature, getUserData, or updateUserData to interact with the identity service. Register an IdentifyKitListener to react to state changes.
val identifyKit = IdentifyKit.default
identifyKit.add(object : IdentifyKitListener {
override fun onCredentialsUpdated(credentials: Credentials?) { }
override fun onSessionSignatureUpdated(signature: Signature?) { }
override fun onCredentialsValidationFailed(exception: Exception) { }
})
identifyKit.credentials = Credentials(token = "<token>")
// suspending; never throws, failures come back in the Result
identifyKit.getSessionSignature().onSuccess { signature ->
// use signature
}.onFailure { error ->
// handle error
}signature and userData are cached for ten seconds and then cleared, with listeners notified of the null. Read them fresh from getSessionSignature and getUserData at the point of use rather than holding on to a copy.
A signature is what associates a user with their votes in InteractKit, and what an embedded Experience asks for over the LauncherKit bridge:
// attribute votes to this user
identifyKit.getSessionSignature().onSuccess { signature ->
interactKit.login(signature) { success -> /* now voting as that user */}
}
// let an embedded Experience use the same identity
experienceView.identify = identifyKit
identifyKit.logout() // clears credentials, signature and user dataProperties
Functions
Registers a listener to receive identity state change notifications.
Requests a session signature based on the user's current identity.
Fetches the user data associated with the current identity.
Unregisters a previously added listener.