4. 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.

To create a Sentiance user, you need to associate them with a user in your system. This process involves providing a unique user identifier from your system to Sentiance. In return, Sentiance generates a temporary authentication code, specifically linked to this user, through secure server-to-server communication. You can then use this authentication code with the Sentiance SDK to create the Sentiance user associated with the provided user identifier. This ensures proper linkage between Sentiance users and users in your system, enabling seamless integration and personalized user experiences while maintaining security and privacy measures. The Sentiance SDK can then deliver valuable insights based on the user's behavior and preferences.

Here are the user creation steps:

  1. When you decide to create a Sentiance user in your app, contact your backend and request a Sentiance authentication code.

  2. On your backend, create a corresponding request towards the Sentiance backend, including your user identifier. This request will be authenticated using a Sentiance API Key, which you can obtain from the Sentiance Insights Dashboard. Please remember that this API Key must never be transmitted to your app to maintain security.

  3. Retrieve the authentication code provided by Sentiance from your backend and forward it to your app.

  4. In your app, use this authentication code to create the Sentiance user as shown below.

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.

let options = SENTUserCreationOptions(authenticationCode: "authenticationCode")

Sentiance.shared.createUser(options: options) { result, error in
    guard let result = result else {
        NSLog("User creation failed with reason \(error!.failureReason)")
    NSLog("Created a user with ID: \(result.userInfo.userId)")

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.

Last updated