React Native SDK
This guide demonstrates how to easily implement our SDK for chat.
Installation
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-sdk
Configuring the application
To 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.
Initialize the SDK
To initialize the SDK, use the initialize
method:
async initialize(): Promise<void>
Set Identity
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.
Set the configuration parameters
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. |
Enabling and controlling the chat
You can enable and control the chat widget using the following method:
open
To display the widget.
async startChat(): Promise<void>
Next steps
After your client is set up, now you can configure the Sinch Chat channel in the Conversation API and start sending and receiving messages.