Setup

Nabla React Native SDK Installation & Quick Start

Integrating the SDK

The Nabla React Native SDK is available on the npm Registery.

⚠️

It's compatible:

  • On Android with Android 8 (API Level 23) and higher: Make sure your android/build.gradle file is well configured:
    • minSdkVersion should be >= 23
    • compileSdkVersion should be >= 32 (this doesn't impact your app's minimum Android supported version)
  • On iOS with iOS 13 and higher.

Install the SDK by running:

yarn add @nabla/react-native-messaging-ui @nabla/react-native-messaging-core @nabla/react-native-core

or

npm install --save @nabla/react-native-messaging-ui @nabla/react-native-messaging-core @nabla/react-native-core

And then run pod install in your ios directory, in order to install the native dependencies.

⚠️

Our React Native SDK is still in early alpha. Some features are missing compared to the native SDKs. We are actively working on adding them.

Contact us if you are missing something important for your app.

Setup

You are now ready to set up the Nabla SDK.
The first thing is to initialize the SDK and NablaMessagingModule before calling any of the API endpoints.

await NablaMessagingClient.initializeMessagingModule();
await NablaClient.getInstance().initialize("YOUR_API_KEY");

The NablaClient can then be accessed from anywhere with NablaClient.getInstance().

Authenticate the app user

Once a user is authenticated in the app, you need to authenticate them to the Nabla's SDK so that they can securely access their conversations.

The authenticate(userId:provideAuthTokens:) method requires a provideAuthTokens promise.

It will be called every time the Nabla SDK needs to authenticate the user, and you are responsible for providing an accessToken and a refreshToken from your backend.

See server side documentation for more details.

NablaClient.getInstance().authenticate(userId, async () => {
  // fetch refresh and access tokens
  return new AuthTokens(refreshToken, accessToken);
});

⚠️

Make sure you call authenticate before calling any other method of the SDK, otherwise an AuthenticationError will be returned.

Your first start

You can now launch your app to ensure everything goes well, and you're ready to start integrating UI components.


Did this page help you?