[admob][ios] Fix an issue whereby interstitials on iOS could not be reused with the same adUnit ID

This commit is contained in:
Elliot Hesp 2017-07-04 15:39:56 +01:00
parent 43410bbadd
commit 92b3860230
2 changed files with 14 additions and 4 deletions

View File

@ -68,6 +68,11 @@ RCT_EXPORT_METHOD(rewardedVideoShowAd:
[rewardedVideo show]; [rewardedVideo show];
} }
RCT_EXPORT_METHOD(clearInterstitial:
(NSString *) adUnit) {
if (_interstitials[adUnit]) [_interstitials removeObjectForKey:adUnit];
}
- (RNFirebaseAdMobInterstitial *)getOrCreateInterstitial:(NSString *)adUnit { - (RNFirebaseAdMobInterstitial *)getOrCreateInterstitial:(NSString *)adUnit {
if (_interstitials[adUnit]) { if (_interstitials[adUnit]) {
return _interstitials[adUnit]; return _interstitials[adUnit];

View File

@ -1,4 +1,4 @@
import { NativeModules } from 'react-native'; import { NativeModules, Platform } from 'react-native';
import { statics } from './'; import { statics } from './';
import AdRequest from './AdRequest'; import AdRequest from './AdRequest';
import { nativeToJSError } from '../../utils'; import { nativeToJSError } from '../../utils';
@ -8,6 +8,11 @@ const FirebaseAdMob = NativeModules.RNFirebaseAdMob;
export default class Interstitial { export default class Interstitial {
constructor(admob: Object, adUnit: string) { constructor(admob: Object, adUnit: string) {
// Interstitials on iOS require a new instance each time
if (Platform.OS === 'ios') {
FirebaseAdMob.clearInterstitial(adUnit);
}
this.admob = admob; this.admob = admob;
this.adUnit = adUnit; this.adUnit = adUnit;
this.loaded = false; this.loaded = false;