React Native SDK
Getting started with the Appnext React Native SDK
Step 1: Initial build
On your project go over to the app gradle and add the url "https://dl.appnext.com/" Under all projects as follows:
allprojects {
repositories {
maven {
url "https://dl.appnext.com/"
}
}
}
In package.json add the npm package dependency to add the react native appnext sdk to your project.
Build the project.
Step 2: Add Ads to your app
Interstitial
Import {Interstitial}
from 'react-native-appnext';
Use the config params to set your preferences (See more options on main documentation).
For example:
const config = {specificCategories:'SHOPPING' };
Interstitial.setConfig(config);
Add listeners for onAdLoaded (See more options on main documentation):
Interstitial.onAdLoaded((msg: String) => {
console.log(msg);
});
Load the ad:
Interstitial.load('placementID',
(err: String) => {
console.log(err);
},
(msg: String) => {
console.log(msg);
})
Finally, show the ad:
Interstitial.showAd();
FullScreen
Import {FullScreen}
from 'react-native-appnext';
Use the config params to set your preferences (See more options on main documentation).
For example:
const config = {specificCategories:'SHOPPING' };
FullScreen.setConfig(config);
Add listeners for onAdLoaded (See more options on main documentation)
FullScreen.onAdLoaded((msg: String) => {
console.log(msg);
});
Load the ad:
FullScreen.load('placementID',
(err: String) => {
console.log(err);
},
(msg: String) => {
console.log(msg);
});
Finally, show the ad:
FullScreen.showAd();
Rewarded
Import {Rewarded}
from 'react-native-appnext';
Use the config params to set your preferences (See more options on main documentation).
For example:
const config = {specificCategories:'SHOPPING' };
Rewarded.setConfig(config);
Add listeners for onAdLoaded (See more options on main documentation)
Rewarded.onAdLoaded((msg: String) => {
console.log(msg);
});
Load the ad:
Rewarded.load('placementID',
(err: String) => {
console.log(err);
},
(msg: String) => {
console.log(msg);
});
Finally, show the ad:
Rewarded.showAd();
Banner
Import {BannerView}
from 'react-native-appnext';
Place the view in the selected location on the screen by adding
<BannerView placementId="pid"/>
See more options for all of the above on Appnext main documentation.
Updated over 1 year ago