[admob][android] Standardise adunit / adUnit

This commit is contained in:
Elliot Hesp 2017-05-27 17:03:09 +01:00
parent 9c2d4a73d6
commit 4852cae988
2 changed files with 22 additions and 14 deletions

View File

@ -6,11 +6,11 @@ const FirebaseAdMob = NativeModules.RNFirebaseAdmob;
export default class Interstitial {
constructor(admob: Object, adunit: string) {
constructor(admob: Object, adUnit: string) {
this.admob = admob;
this.adUnit = adunit;
this.adUnit = adUnit;
this.loaded = false;
this.admob.on(`interstitial_${adunit}`, this._onInterstitialEvent.bind(this));
this.admob.on(`interstitial_${adUnit}`, this._onInterstitialEvent.bind(this));
}
/**

View File

@ -1,5 +1,6 @@
import { NativeModules, NativeEventEmitter } from 'react-native';
import Interstitial from './Interstitial';
import RewardedVideo from './RewardedVideo';
import AdRequest from './AdRequest';
import Banner from './Banner';
import { Base } from './../base';
@ -12,11 +13,23 @@ export default class Admob extends Base {
constructor() {
super();
FirebaseAdMobEvt.addListener('interstitial_event', this._onInterstitialEvent.bind(this));
FirebaseAdMobEvt.addListener('rewarded_video_event', this._onRewardedVideoEvent.bind(this));
}
_onInterstitialEvent(event) {
const { adunit } = event;
const jsEventType = `interstitial_${adunit}`;
const { adUnit } = event;
const jsEventType = `interstitial_${adUnit}`;
if (!this.hasListeners(jsEventType)) {
// TODO
}
this.emit(jsEventType, event);
}
_onRewardedVideoEvent(event) {
const { adUnit } = event;
const jsEventType = `rewarded_video_${adUnit}`;
if (!this.hasListeners(jsEventType)) {
// TODO
@ -29,6 +42,10 @@ export default class Admob extends Base {
return new Interstitial(this, adUnit);
}
rewarded(adUnit: string) {
return new RewardedVideo(this, adUnit);
}
static get statics() {
return statics;
}
@ -44,13 +61,4 @@ export const statics = {
onAdClosed: 'onAdClosed',
onAdFailedToLoad: 'onAdFailedToLoad',
},
RewardedEventTypes: {
onRewarded: 'onRewarded',
onRewardedVideoAdLeftApplication: 'onRewardedVideoAdLeftApplication',
onRewardedVideoAdClosed: 'onRewardedVideoAdClosed',
onRewardedVideoAdFailedToLoad: 'onRewardedVideoAdFailedToLoad',
onRewardedVideoAdLoaded: 'onRewardedVideoAdLoaded',
onRewardedVideoAdOpened: 'onRewardedVideoAdOpened',
onRewardedVideoStarted: 'onRewardedVideoStarted',
},
};