diff --git a/lib/modules/admob/index.js b/lib/modules/admob/index.js index 2ca393cb..c044646b 100644 --- a/lib/modules/admob/index.js +++ b/lib/modules/admob/index.js @@ -16,11 +16,22 @@ import EventTypes, { RewardedVideoEventTypes, } from './EventTypes'; +import type FirebaseApp from '../core/firebase-app'; + +type NativeEvent = { + adUnit: string, + payload: Object, + type: string, +} + export default class AdMob extends ModuleBase { static _NAMESPACE = 'admob'; static _NATIVE_MODULE = 'RNFirebaseAdMob'; - constructor(firebaseApp: Object, options: Object = {}) { + _appId: ?string; + _initialized: boolean; + + constructor(firebaseApp: FirebaseApp, options: Object = {}) { super(firebaseApp, options, true); this._initialized = false; @@ -30,7 +41,7 @@ export default class AdMob extends ModuleBase { this._eventEmitter.addListener('rewarded_video_event', this._onRewardedVideoEvent.bind(this)); } - _onInterstitialEvent(event) { + _onInterstitialEvent(event: NativeEvent): void { const { adUnit } = event; const jsEventType = `interstitial_${adUnit}`; @@ -41,7 +52,7 @@ export default class AdMob extends ModuleBase { this.emit(jsEventType, event); } - _onRewardedVideoEvent(event) { + _onRewardedVideoEvent(event: NativeEvent): void { const { adUnit } = event; const jsEventType = `rewarded_video_${adUnit}`; @@ -52,7 +63,7 @@ export default class AdMob extends ModuleBase { this.emit(jsEventType, event); } - initialize(appId: string) { + initialize(appId: string): void { if (this._initialized) { this.log.warn('AdMob has already been initialized!'); } else { @@ -62,7 +73,7 @@ export default class AdMob extends ModuleBase { } } - openDebugMenu() { + openDebugMenu(): void { if (!this._initialized) { this.log.warn('AdMob needs to be initialized before opening the dev menu!'); } else { @@ -71,11 +82,11 @@ export default class AdMob extends ModuleBase { } } - interstitial(adUnit: string) { + interstitial(adUnit: string): Interstitial { return new Interstitial(this, adUnit); } - rewarded(adUnit: string) { + rewarded(adUnit: string): RewardedVideo { return new RewardedVideo(this, adUnit); }