Adding the SDK and initializing it
Nabla React Native SDK installation
The Nabla React Native SDK is compatible:
- On Android with Android 6 (API Level 23) and higher: Make sure your
android/build.gradle
file is well configured:
minSdkVersion
should be >= 23compileSdkVersion
should be >= 33 (this doesn't impact your app's minimum Android supported version)- You need to set up desugaring libraries in your
build.gradle
file as mentioned in the desugaring guide- Also, to support API 23, you will need to add
vectorDrawables.useSupportLibrary true
in thedefaultConfig
section of yourbuild.gradle
file, as mentioned in Vector Drawable compat guide.- On iOS with iOS 13 and higher: Make sure your
ios/Podfile
is well configured:
platform :ios, '13.0'
(or higher)
Add the dependency
The Nabla React Native SDK is available on the npm Registery.
Expo workflow specifics
As the React Native SDK is using custom native code, it requires to use development builds as explained in Expo documentation.
Install the SDK by running:
yarn add @nabla/react-native-core
or
npm install --save @nabla/react-native-core
You can also add the desired Nabla dependencies:
@nabla/react-native-messaging-ui
@nabla/react-native-messaging-core
@nabla/react-native-scheduling
As the Nabla SDK relies on Sentry
to send anonymized events to Nabla servers to help us improve features like video calls,
you will need to add the dependency in the iOS/Podfile
with a custom configuration to be compatible with the React Native project.
target 'AppName' do
...
pod 'Sentry', :modular_headers => true
...
end
And then run pod install
in your ios
directory, in order to install the native dependencies.
Initialize the SDK
Next, initialize the SDK and any module you want to add.
await NablaMessagingClient.initializeMessagingModule(); // If you want the messaging module
await NablaVideoCallClient.initializeVideoCallModule(); // If you want to add video call capabilities
await NablaSchedulingClient.initializeSchedulingModule(); // if you want the scheduling feature
await NablaClient.getInstance().initialize(
new Configuration("YOUR_API_KEY"),
async () => {
// fetch refresh and access tokens
return new AuthTokens(refreshToken, accessToken);
}
);
The NablaClient
can then be accessed from anywhere with NablaClient.getInstance()
.
To generate a mobile SDK API key, open your Nabla Console, go to the "Developers" tab, then to the "API keys" section, "Mobile SDK API keys" sub-tab, and click on "Add mobile SDK API key".
Updated 6 months ago