Initial SDK Setup

Using rnpm

  1. npm install react-native-appboy-sdk@latest --save
  2. rnpm link
  3. Add the Appboy repository to your project:
// top-level build.gradle
allprojects {
  repositories {
    maven { url "http://appboy.github.io/appboy-android-sdk/sdk" }
  }
}

Without rnpm

  1. npm install react-native-appboy-sdk@latest --save
  2. Link the project by adding the following:
// settings.gradle

include ':react-native-appboy-sdk'
project(':react-native-appboy-sdk').projectDir = new File(settingsDir, '../node_modules/react-native-appboy-sdk/android')
// top-level build.gradle

allprojects {
  repositories {
    maven { url "http://appboy.github.io/appboy-android-sdk/sdk" }
  }
}
// app build.gradle

dependencies {
    compile project(':react-native-appboy-sdk')
}

Java changes

Add our AppboyReactPackage to the getPackages() method of your Application class.

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new AppboyReactPackage()
      );
    }

Completing the integration

  1. Follow the directions at our public documentation to finish your integration.
  2. When you need to make Appboy calls from javascript, use the following declaration to import the javascript module:

const ReactAppboy = require('react-native-appboy-sdk');

Analytics

Logging Custom Events

See the Android integration instructions for in depth discussion of event tracking best practices and interfaces.

var properties = {};
properties["KeyOne"] = "Val1";
ReactAppboy.logCustomEvent("cordovaCustomEventWithProperties", properties);

Setting Custom Attributes

See the Android integration instructions for in depth discussion of attribute tracking best practices and interfaces.

ReactAppboy.setFirstName("firstName");

Logging Purchases

See the Android integration instructions for in depth discussion of revenue tracking best practices and interfaces.

var properties = {};
properties["KeyOne"] = "ValueOne";
ReactAppboy.logPurchase("testPurchaseWithNullCurrency", 10, null, 5, properties);