This module provides react-native bindings for the Tapjoy SDK.
Tapjoy is a monetization and distribution services provider for mobile applications. Tapjoy’s goal is to maximize the value of every user for freemium mobile app publishers. Its Marketing Automation and Monetization Platform for mobile apps uses market leading data science, user segmentation and predictive analytics to drive deeper engagement and optimize revenue from every user.
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. You don't build a “mobile web app”, an “HTML5 app”, or a “hybrid app”. You build a real mobile app that's indistinguishable from an app built using Objective-C or Java.
npm install react-native-tapjoy@latest --save
react-native link
- In the XCode's "Project navigator", right click on your project's Libraries folder ➜
Add Files to <...>
- Go to
node_modules
➜react-native-tapjoy
➜ios
➜ selectRNTapjoy.xcodeproj
- Add
libRNTapjoy.a
toBuild Phases -> Link Binary With Libraries
- Add the Tapjoy SDK to your XCode project as described on the Tapjoy website
NOTE: You have to manually integrate the Push notifications feature as described on the Tapjoy website, because it requires access to the didFinishLaunchingWithOptions:` method in your application’s app delegate file.
-
Add the following lines to
android/settings.gradle
:include ':react-native-tapjoy' project(':react-native-tapjoy').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-tapjoy/android')
-
Update the android build tools version to
2.2.+
inandroid/build.gradle
:buildscript { ... dependencies { classpath 'com.android.tools.build:gradle:2.2.+' // <- USE 2.2.+ version } ... } ...
-
Update the gradle version to
2.14.1
inandroid/gradle/wrapper/gradle-wrapper.properties
:... distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
-
Add the compile line to the dependencies in
android/app/build.gradle
:dependencies { compile project(':react-native-tapjoy') }
-
Add the import and link the package in
MainApplication.java
:import de.reimerm.tapjoy.TapjoyPackage; // <-- add this import public class MainApplication extends Application implements ReactApplication { @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new TapjoyPackage() // <-- add this line ); } }
-
Add the Tapjoy SDK to your Android project as described on the Tapjoy website.
import Tapjoy from 'react-native-tapjoy';
const options = {
sdkKeyIos: "12345",
sdkKeyAndroid: "12345",
gcmSenderIdAndroid: "12345",
debug: true
};
const tapjoy = new Tapjoy(options);
tapjoy.initialise()
.then((info) => {
console.log(info);
// Connect successful
// You may add placements here
})
.catch((error) => console.log(error));
tapjoy.addPlacement("TestPlacement", function (evt) {
if (evt.onContentDismiss) {
// You may want to refresh the currency balance here,
// or request new content
} else if (evt.onRequestSuccess) {
} else if (evt.onRequestFailure) {
console.log(evt.errorMessage);
} else if (evt.onContentReady) {
} else if (evt.onContentShow) {
} else if (evt.onPurchaseRequest) {
console.log("Request ID: " + evt.requestId);
console.log("Token: " + evt.token);
console.log("Product ID: " + evt.productId);
} else if (evt.onRewardRequest) {
console.log("Request ID: " + evt.requestId);
console.log("Token: " + evt.token);
console.log("Item ID: " + evt.itemId);
console.log("Quantity: " + evt.quantity);
}
}).catch((error) => console.log(error));
tapjoy.requestContent("TestPlacement")
.catch((error) => console.log(error));
tapjoy.showPlacement("TestPlacement")
.catch((error) => console.log(error));
tapjoy.getCurrencyBalance()
.then((resp) => {
console.log("Your currency balance: " + resp.value + " " + resp.currencyBalance);
})
.catch((error) => console.log(error));
tapjoy.listenForEarnedCurrency(function (evt) {
console.log("Currently earned " + evt.value + " " + evt.currency);
}).catch((error) => console.log(error));