[admob][android] Export interstitial JS module

This commit is contained in:
Elliot Hesp 2017-05-26 15:18:57 +01:00
parent b1e9561633
commit dd1262ca86
3 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,22 @@
export default class AdRequest {
constructor() {
this._props = {
keywords: [],
};
}
build() {
return this._props;
}
addTestDevice() {
this._props.testDevice = true;
return this;
}
addKeyword(word: string) {
this._props.keywords.push(word);
return this;
}
}

View File

@ -0,0 +1,29 @@
import { NativeModules } from 'react-native';
const FirebaseAdMob = NativeModules.RNFirebaseAdmob;
export default class Interstitial {
constructor(admob: Object, eventListener: Object, adunit: string) {
this.admob = admob;
this.adUnit = adunit;
eventListener.addListener('interstitial_event', this._onInterstitialEvent.bind(this));
}
_onInterstitialEvent(event) {
}
loadAd(request: AdRequest) {
return FirebaseAdMob.interstitialLoadAd(this.adUnit, request);
}
isLoaded() {
return true;
}
show() {
return FirebaseAdMob.interstitialShowAd(this.adUnit);
}
}

View File

@ -1 +1,20 @@
export const Banner = require('./Banner');
import Interstitial from './Interstitial';
import AdRequest from './AdRequest';
import Banner from './Banner';
import Base from './../base';
const FirebaseAdMob = NativeModules.RNFirebaseAdMob;
const FirebaseAdMobEvt = new NativeEventEmitter(FirebaseAdMob);
export default class Admob extends Base {
interstitial(adUnit: string) {
return new Interstitial(this, FirebaseAdMobEvt, adUnit);
}
}
export const statics = {
Banner,
AdRequest,
};