Installation

Our React Native SDK provides pre-built chat UI components for your React Native application.

You can use the React Native SDK with React Native versions 0.64 and higher.

To install the React Native SDK, you can choose from either of two TalkJS modules, depending on whether you would like to build using Expo:

ModuleWorks with ExpoWorks with Expo Go
@talkjs/react-nativeNoNo
@talkjs/expoYesNo

Using @talkjs/react-native

The @talkjs/react-native module allows you to build React Native apps fast.

Because some of its dependencies are incompatible with Expo, @talkjs/react-native is not suited for building on Expo. If you would like to build React Native apps using Expo, you can use @talkjs/expo instead.

Installation

Install the React Native SDK into your app from the command line. To ensure that the module can be loaded correctly, make sure also to explicitly install the SDK's peer dependencies, as follows (with either your npm or yarn package manager):

Note: React Native CLI doesn't auto-link libraries with native modules when those libraries are transitive dependencies. To load the native modules correctly, you instead have to explicitly install the SDK's peer dependencies as shown in the following.

npm:

1npm install @talkjs/react-native @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview @react-native-async-storage/async-storage

yarn:

1yarn add @talkjs/react-native @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview @react-native-async-storage/async-storage

If you are targeting iOS, you'll also need to add the following to your Podfile in your app's target section:

1pod 'Firebase', :modular_headers => true
2pod 'FirebaseCore', :modular_headers => true
3pod 'GoogleUtilities', :modular_headers => true
4$RNFirebaseAsStaticFramework = true

Afterwards, run:

1npx pod-install

Usage

To import the React Native library into your project, add one of the following statements to your app's code, depending on what module system you are using:

ES6/TypeScript:

1import * as TalkjsRn from '@talkjs/react-native';

CommonJS:

1const TalkjsRn = require('@talkjs/react-native');

Once you have imported the library, to start using TalkJS in your project, follow the React Native getting started guide.

Using @talkjs/expo

The @talkjs/expo module allows you to build React Native apps fast on Expo. The module does not contain native code and it relies on dependencies that support Expo. This means that you can use it to build with Expo.

Because some of its dependencies contain native code, @talkjs/expo does not work with Expo Go.

Installation

Install the React Native SDK and its dependencies from the command line, as follows:

1expo install @talkjs/expo @notifee/react-native react-native-webview @react-native-async-storage/async-storage expo-build-properties

Configure Notifee

This step is required for Expo users even if you don't plan to enable push notifications, otherwise building on Android will fail.

The Notifee package requires its native modules to be defined under extraMavenRepos in your project's app.json as shown:

JSON
1{
2 "expo": {
3 "plugins": [
4 // Other plugins
5 [
6 "expo-build-properties",
7 {
8 "android": {
9 "extraMavenRepos": [
10 "../../node_modules/@notifee/react-native/android/libs"
11 ]
12 }
13 }
14 ]
15 ]
16 }
17}

Usage

To import the React Native library into your project, add one of the following statements to your code, depending on what module system you are using:

ES6/TypeScript:

1import * as TalkjsRn from '@talkjs/expo';

CommonJS:

1const TalkjsRn = require('@talkjs/expo');

Once you have imported the library, to start using TalkJS in your project, follow the React Native getting started guide.

Beta release

Both @talkjs/react-native and @talkjs/expo are released in a beta state. This is because currently, the React Native SDK does not yet have all the features that are available in the TalkJS JavaScript SDK. As soon as the React Native SDK parallels the features available in the JavaScript SDK, we will release version 1.0.0 of the packages.

That said, we always maintain backward compatibility, so both packages are stable for production use.