react-native-appnext
v1.1.1
Published
Appnext support for **Android** and **iOS**
Downloads
10
Readme
react-native-appnext
Appnext support for Android and iOS
Getting started
$ npm install react-native-appnext --save
Mostly automatic installation
$ react-native link react-native-appnext
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-appnext
and addRNAppnext.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNAppnext.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import me.jerson.mobile.ads.appnext.RNAppNextPackage;
to the imports at the top of the file - Add
new RNAppNextPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-appnext' project(':react-native-appnext').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-appnext/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-appnext')
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.appnext.base.Appnext;
to the imports at the top of the file - Add
Appnext.init(getApplicationContext());
to the theonCreate()
methodpublic void onCreate() { //... Appnext.init(getApplicationContext()); //... }
Usage
import Appnext from 'react-native-appnext';
eventHandlers = [
onAdLoaded,
onRewardedVideoEnded,
onRewardedVideoClicked,
onRewardedVideoClosed,
onInterstitialClicked,
onInterstitialClosed,
onFullScreenVideoEnded,
onFullScreenVideoClicked,
onFullScreenVideoClosed
];
Appnext.setupAd(placementId);
Appnext.showRewardedVideo(placementId);
Appnext.showInterstitial(placementId);
Appnext.showFullScreenVideo(placementId);
Appnext.loadAd(category = "Entertainment")
Appnext.removeAd(adId);
Appnext.adClicked(adId);
Appnext.adImpression(adId);
Appnext.videoStarted(adId);
Appnext.videoEnded(adId);
Appnext.privacyClicked(adId);
Appnext.addEventListener(type, handler);
Appnext.removeEventListener(type, handler);
Appnext.removeAllListeners();