diff --git a/lib/modules/admob/Interstitial.js b/lib/modules/admob/Interstitial.js index c8b20116..8076044f 100644 --- a/lib/modules/admob/Interstitial.js +++ b/lib/modules/admob/Interstitial.js @@ -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)); } /** diff --git a/lib/modules/admob/index.js b/lib/modules/admob/index.js index 2020eea1..5ee18f3b 100644 --- a/lib/modules/admob/index.js +++ b/lib/modules/admob/index.js @@ -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', - }, };