This guide demonstrates how to easily implement our SDK for chat.
The React Native SDK is available using npm.
To install it, run the following command in a terminal or command prompt:
npm install sinch-chat-react-native-sdkTo set up your application to start sending and receiving messages, you need to perform the following steps:
- Initialize the SDK as soon as the application starts.
- Set the identity of the user.
- Enable the chat functionality.
To initialize the SDK, use the initialize method:
async initialize(): Promise<void>We need to authorize the user next. To do that, call this method as early as possible to authorize the user:
async setIdentity(options: IdentityOptions): Promise<void>interface IdentityOptions {
region: string;
clientID: string;
projectID: string;
configID: string;
userID?: string;
secret?: string;
}After correct authorization, the token will be saved in local storage.
To connect your Sinch Chat client to your Sinch account, you need to set the following parameters:
| Parameter | Description |
|---|---|
| projectId | Get your project ID from your Sinch Dashboard. |
| clientId | Get your client ID from your Sinch Dashboard. |
| region | Use either EU for Europe or US for the United States. |
You can enable and control the chat widget using the following method:
To display the widget.
async startChat(): Promise<void>After your client is set up, now you can configure the Sinch Chat channel in the Conversation API and start sending and receiving messages.