Quickstart

1. Minimum Requirements

  • React Native: 0.71.6
  • Node 14 or newer
  • Ruby 2.7.6
  • iOS: 12.4
  • Android: 5.0 (API 21)

2. SDK Integration

The first step in integrating with your app is to install the Tapjoy React Native Plugin. We support NPM and Yarn.

NPM

npm install tapjoy-react-native-sdk

Yarn

yarn add tapjoy-react-native-sdk

You can then import Tapjoy into your application to use the plugin:

import {Tapjoy, TJPlacement} from 'tapjoy-react-native-sdk'

Add App Permissions (for Android)

The ACCESS_WIFI_STATE permission can optionally be included in your manifest:

<manifest ...>
  ...
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  ...
</manifest>

3. Connect to Tapjoy

The connect call is how we initialise the Tapjoy SDK. You should do this as soon as possible after your app launches

try {

    let sdkKey = Platform.OS === 'ios' ? 'ios-sdk-key' : 'android-sdk-key'
    let flags: object = {TJC_OPTION_USER_ID: 'userId'};

    await Tapjoy.connect(sdkKey, flags);

} catch (error) {
    console.error(error);            
}

Once you have finished configuing Tapjoy you can build and run your application.

In the Tapjoy Dashboard, if you click on the "Analytics" from the top navigation bar and then "Real-time" tab in the navigation bar on the left, you should see some activity from your application moments after you run it.

Congratulations! You now have Tapjoy working in your application.

4. Request App Tracking Transparency authorization

If your application is designed to use App Tracking Transparency, to display the dialog to request permission for accessing the IDFA, update your Info.plist by including the NSUserTrackingUsageDescription key along with a custom message to describe this permission to use IDFA in your application.

Next install the react-native-tracking-transparency package:

yarn add react-native-tracking-transparency

Import the library, and then show the permission dialog:

import {
    getTrackingStatus,
    requestTrackingPermission,
} from 'react-native-tracking-transparency';

...

let trackingStatus = await getTrackingStatus();
if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
    await Tapjoy.connect(sdkKey, flags);
}else{
    trackingStatus = await requestTrackingPermission();
    await Tapjoy.connect(sdkKey, flags);
}