3. User Creation

After initializing the SDK, you must create a Sentiance user in order to activate the various SDK features.

1. Obtain an Authentication Code

This step requires server-side development.
A Sentiance user must be linked to a user in your system. Therefore, to create a Sentiance user, you first provide a unique user identifier from your system, and in return Sentiance provides a temporary authentication code that is linked to this user. This step happens with a server-to-server communication. You then use this code on the SDK to create the Sentiance user.
Here are the user creation steps:
  1. 1.
    In your app, when decided to create a Sentiance user, contact your backend and request a Sentiance authentication code.
  2. 2.
    On your backend, create a corresponding request towards the Sentiance backend, which will include your user identifier. This request is authenticated using a Sentiance API Key (which you can obtain from the Sentiance Insights Dashboard). This key must never be transmitted to your app, which is why this step requires a backend-to-backend interaction.
  3. 3.
    Retrieve the authentication code provided by Sentiance and forward it to your app.
  4. 4.
    In your app, create a Sentiance user using this authentication code.

2. Create a Sentiance User

After obtaining the authentication code in the step above, create a user by passing the code to the SDK's createUser method.
val options = UserCreationOptions.Builder(authenticationCode).build()
Sentiance.getInstance(context).createUser(options).addOnCompleteListener { operation ->
if (operation.isSuccessful) {
val userInfo = operation.result.userInfo
Log.d(TAG, "Created a user with ID: ${userInfo.userId}")
} else {
val error = operation.error
Log.e(TAG, "User creation failed with reason ${}. Details: ${error.details}")
The SDK supports the presence of only one Sentiance user on the device at a time. If your app supports multiple users (e.g. via a login flow), you can utilize the SDK's reset functionality to remove the existing user from the device, before creating a new one.
For more information on user creation, check out this page.