Links

user-context

Note that the user context feature is in Early Access. The API is subject to change in the future.

Install the module

Run the following command to install the module (make sure to install the core module beforehand):
npm i @sentiance-react-native/user-context

Import the module

import SentianceUserContext from "@sentiance-react-native/user-context";
You can find a reference to all the types mentioned on this page here.

Request the current user context data

// returns Promise<UserContext>
const userContext = await SentianceUserContext.requestUserContext();

Listen to user context updates

import {addUserContextUpdateListener} from "@sentiance-react-native/user-context";
const subscription = addUserContextUpdateListener(userContext => {
// User context update received
});
// Don't forget to unsubscribe, typically in componentWillUnmount
subscription.remove();