react-native-tapjoy-indi
v1.0.16
Published
A library for accessing the basic Tapjoy functionality in React Native (currently works only for Android)
Downloads
2
Readme
React Native module for Tapjoy - only works for Android now (and not fully yet - see Notes in the bottom)
react-native-tapjoy-android
Getting started
$ npm install react-native-tapjoy-android --save
Mostly automatic installation
$ react-native link react-native-tapjoy-android
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.coldevel.rntapjoyandroid.RNTapjoyAndroidPackage;
to the imports at the top of the file - Add
new RNTapjoyAndroidPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-tapjoy-android' project(':react-native-tapjoy-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-tapjoy-android/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-tapjoy-android')
Usage
import TapjoySDK from 'react-native-tapjoy-android';
// Somewhere in app.js / index.js at the top of the file
TapjoySDK.initialize(
// See https://dev.tapjoy.com/sdk-integration/android/getting-started-guide-publishers-android/ to locate your SDK key
TAPJOY_SDK_KEY,
() => console.log('Initialization success'),
() => console.log('Initialization failure'),
);
// When you want to load an ad (probably somewhere early, too, but after initialization succeeded above
TapjoySDK.requestPlacement(
placementName,
() => console.log('Ad ready to show'),
() => console.log('Ad not ready to show'),
);
// When you want to show an ad
TapjoySDK.showPlacement(
placementName,
() => console.error('Error showing Ad'),
() => console.log('Ad shown'),
() => console.log('Ad dismissed'),
);