[admob] A few internal fixes
This commit is contained in:
parent
f0610082de
commit
bddccb0872
|
@ -1,3 +1,6 @@
|
|||
/**
|
||||
* @flow
|
||||
*/
|
||||
export default {
|
||||
onAdLoaded: 'onAdLoaded',
|
||||
onAdOpened: 'onAdOpened',
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
import { NativeModules, Platform } from 'react-native';
|
||||
import { Platform } from 'react-native';
|
||||
import { statics } from './';
|
||||
import AdRequest from './AdRequest';
|
||||
import { SharedEventEmitter } from '../../utils/events';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
import { nativeToJSError } from '../../utils';
|
||||
|
||||
const FirebaseAdMob = NativeModules.RNFirebaseAdMob;
|
||||
import type AdMob from './';
|
||||
|
||||
let subscriptions = [];
|
||||
|
||||
export default class Interstitial {
|
||||
constructor(admob: Object, adUnit: string) {
|
||||
_admob: AdMob;
|
||||
|
||||
constructor(admob: AdMob, adUnit: string) {
|
||||
// Interstitials on iOS require a new instance each time
|
||||
if (Platform.OS === 'ios') {
|
||||
FirebaseAdMob.clearInterstitial(adUnit);
|
||||
getNativeModule(admob).clearInterstitial(adUnit);
|
||||
}
|
||||
|
||||
for (let i = 0, len = subscriptions.length; i < len; i++) {
|
||||
|
@ -20,7 +22,7 @@ export default class Interstitial {
|
|||
}
|
||||
subscriptions = [];
|
||||
|
||||
this.admob = admob;
|
||||
this._admob = admob;
|
||||
this.adUnit = adUnit;
|
||||
this.loaded = false;
|
||||
SharedEventEmitter.removeAllListeners(`interstitial_${adUnit}`);
|
||||
|
@ -67,7 +69,10 @@ export default class Interstitial {
|
|||
adRequest = new AdRequest().addTestDevice().build();
|
||||
}
|
||||
|
||||
return FirebaseAdMob.interstitialLoadAd(this.adUnit, adRequest);
|
||||
return getNativeModule(this._admob).interstitialLoadAd(
|
||||
this.adUnit,
|
||||
adRequest
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +89,7 @@ export default class Interstitial {
|
|||
*/
|
||||
show() {
|
||||
if (this.loaded) {
|
||||
FirebaseAdMob.interstitialShowAd(this.adUnit);
|
||||
getNativeModule(this._admob).interstitialShowAd(this.adUnit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
import { NativeModules } from 'react-native';
|
||||
import { statics } from './';
|
||||
import AdRequest from './AdRequest';
|
||||
import { SharedEventEmitter } from '../../utils/events';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
import { nativeToJSError } from '../../utils';
|
||||
|
||||
const FirebaseAdMob = NativeModules.RNFirebaseAdMob;
|
||||
import type AdMob from './';
|
||||
|
||||
let subscriptions = [];
|
||||
|
||||
export default class RewardedVideo {
|
||||
constructor(admob: Object, adUnit: string) {
|
||||
_admob: AdMob;
|
||||
|
||||
constructor(admob: AdMob, adUnit: string) {
|
||||
for (let i = 0, len = subscriptions.length; i < len; i++) {
|
||||
subscriptions[i].remove();
|
||||
}
|
||||
subscriptions = [];
|
||||
|
||||
this.admob = admob;
|
||||
this._admob = admob;
|
||||
this.adUnit = adUnit;
|
||||
this.loaded = false;
|
||||
SharedEventEmitter.removeAllListeners(`rewarded_video_${adUnit}`);
|
||||
|
@ -62,7 +63,10 @@ export default class RewardedVideo {
|
|||
adRequest = new AdRequest().addTestDevice().build();
|
||||
}
|
||||
|
||||
return FirebaseAdMob.rewardedVideoLoadAd(this.adUnit, adRequest);
|
||||
return getNativeModule(this._admob).rewardedVideoLoadAd(
|
||||
this.adUnit,
|
||||
adRequest
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,7 +83,7 @@ export default class RewardedVideo {
|
|||
*/
|
||||
show() {
|
||||
if (this.loaded) {
|
||||
FirebaseAdMob.rewardedVideoShowAd(this.adUnit);
|
||||
getNativeModule(this._admob).rewardedVideoShowAd(this.adUnit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ export default class AdMob extends ModuleBase {
|
|||
const { adUnit } = event;
|
||||
const jsEventType = `interstitial_${adUnit}`;
|
||||
|
||||
if (!SharedEventEmitter.hasListeners(jsEventType)) {
|
||||
if (SharedEventEmitter.listeners(jsEventType).length === 0) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export default class AdMob extends ModuleBase {
|
|||
const { adUnit } = event;
|
||||
const jsEventType = `rewarded_video_${adUnit}`;
|
||||
|
||||
if (!SharedEventEmitter.hasListeners(jsEventType)) {
|
||||
if (SharedEventEmitter.listeners(jsEventType).length === 0) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue