Initial SDK Setup

360dialog provides a React-Native plugin that offers you the possibility to use the 360dialog SDK from a React-Native mobile application. In this guide, we suppose that you already have a working React-Native app containing an android and/or an ios folders. If it is not the case, please follow the page Get Started First: Building Projects with Native Code.

Step 1: Download the plugin

Use the following command to add the plugin to your project:

$ npm install git+ssh://git@github.com:360dialog/sdk-react-native.git#master --save
$ react-native link

You can alternatively clone our repository using SSH add the plugin locally:

$ git clone git@github.com:360dialog/sdk-react-native.git
$ npm install sdk-react-native/ --save
$ react-native link

Step 2: Integrate the native SDK

In iOS

Follow the following native steps to integrate the native SDK in the react native project located in the ios subfolder

In Android

Attention

We use the JitPack as a Maven distribution service. As the native SDK is hosted in a private GitHub repository, you have to setup your environment as shown on JitPack Private Repositories docs: https://jitpack.io/private#auth before you continue

In your android/build.gradle file add the lines:

allprojects {
    repositories {
        //...
        maven { url 'https://jitpack.io' }
    }
}

Then you may proceed to Step 2: Integrate the SDK

Step 3: Set push notifications

Follow the native Android Push Notifications and iOS push notification integration steps

Step 4: Compile and run

At this point you can already compile and run the application.

react-native run-android
react-native run-ios

The 360dialog SDK will be able to register, receive a device id, send events and receive push paylaods. In the logs (logcat or iOS Console) you should see an output similar to this:

Starting the 360dialog SDK v3.x.x

##################################### SDK device id #################################################
   iyRPX67gMRL4jcbsBhhs4p00000000000000000000000000000000000000000000000000000000000000000000000
#####################################################################################################


##################################### SDK push token #################################################
   8c23510ba6c55ef1d1a3d57e5e5c6e720694ae9a97110000000000000000000000000000000000000000000000000
######################################################################################################

Step 5: Usage

In the react native code, import the 360dialog module as follows

import { D360 } from 'react-native-d360';

then you’ll get access the sdk services as described in

For more examples, you can have a look at our sample app or refer to the React-Native Plugin reference.

Please note that not all native SDK capabilities are exposed to React-Native, and only the methods documented above are available.