React Native

React Native lets you build mobile apps using only JavaScript. It uses the same design as React, letting you compose a rich mobile UI from declarative components.

Here's how you can integrate the WebEngage SDK with your react native apps:

1. Install WebEngage React Native Library

Use the below command in your project directory to install WebEngage React Native library.

npm install react-native-webengage --save

2. Link Dependency

Use this command to automatically link the WebEngage dependency with your project.

react-native link react-native-webengage

You should see the below message in the console after successful linking.

1572

🚧

If you don't see this message in your console, then you can manually link the library by following these steps.

Now that the WebEngage React Native library is linked to your project, you will have to install the SDKs for Android and iOS in the respective native apps of your project.

3. Install Android SDK

If you are building your Android app, follow the Getting started steps to install the Android SDK.

After following the above steps add the following in your onCreate method of your Application class.

import com.webengage.WebengageBridge;


@Override
public void onCreate() {
  super.onCreate();
  WebengageBridge.getInstance();

//...WebEngage initialization
}
import com.webengage.WebengageBridge;



override fun onCreate() {
        super.onCreate()
        WebengageBridge.getInstance();
        // ... Webengage Initialization

       
    }

4. Install iOS SDK

If you are building your iOS app, follow the Getting started steps to install the iOS SDK.

5. Initialize the SDK

Grab a reference to the WebEngage React Native library in your JavaScript file.

import WebEngage from 'react-native-webengage';
var webengage = new WebEngage();

Additionally, if you're using TypeScript, you need to add the following include JSON array object in the /tsconfig.json file

{
    ...
    "include": [
        "src/**/*",
        "index.d.ts"
    ]
}

🚧

Congratulations!

You have successfully integrated WebEngage with your React Native apps and are sending user session data to WebEngage. Please note that it may take up to a few minutes for data to reflect in your dashboard.

Please feel free to drop in a few lines at [email protected] in case you have any further queries. We're always just an email away!


So, what's next?

We recommend that you implement the following integrations with your app before releasing it with WebEngage for the first time: