4. User Creation
After initializing the SDK, you must create a Sentiance user in order to activate the various SDK features.
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.In your app, when decided to create a Sentiance user, contact your backend and request a Sentiance authentication code.
- 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 you app, which is why this step requires a backend-to-backend interaction.
- 3.Retrieve the authentication code provided by Sentiance and forward it to your app.
- 4.In your app, create a Sentiance user using this authentication code.
After obtaining the authentication code in the step above, create a user by passing the code to the SDK's createUser method.
import { createUser } from '@sentiance-react-native/core';
try {
const result = await createUser({ authCode: authenticationCode });
console.log(`Created a user with ID: ${result.userInfo.userId}`);
} catch(e) {
console.log(`User creation failed with error: ${e}`);
}
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.
Last modified 8mo ago