react-native-instream-android
v0.1.0
Published
Instream Facebook ads for React Native android
Downloads
26
Maintainers
Readme
react-native-instream-android
Instream Facebook ads for React Native android
Note: this project is Android only, and not a Component Module, just a method to show Ads activity on top of your React Native app
Installation Process
- download this from npm
npm install react-native-instream-android --save
Follow all the steps in the Getting Started Guide for Facebook SDK and Getting Started Guide for Facebook Audience for Android.
Run
react-native link
to automatically link the library.
manual link process
Edit
android/settings.gradle
:+ include ':react-native-instream-android' + project(':react-native-instream-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-instream-android/android')
Edit
android/app/build.gradle
:dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" + compile project(':react-native-instream-android') }
Edit
android/app/src/main/java/.../MainApplication.java
:+ import com.rninstreamandroid.RNInstreamAndroidPackage;
@Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage() + , new RNInstreamAndroidPackage() ); }
Usage
import Instream from 'react-native-instream-android'
// or
import { Instream } from 'react-native-instream-android'
// or
const Instream = require('react-native-instream-android')
// methods (Android only, will throw Error on iOS)
// callback type
Instream.show("PLACEMENT_ID", () => {
// runs when ads close because users click, skip ad, ad completed or ad error
// your code here
});
// promise type
Instream.show("PLACEMENT_ID").then(() => {
// runs when ads close because users click, skip ad, ad completed or ad error
// your code here
});