Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 9b0be7b

Browse files
Prevent a race condition I just fixed at EddyVerbruggen/nativescript-admob#24
1 parent 77ab04b commit 9b0be7b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/firebase.android.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,19 @@ firebase.admob.showInterstitial = arg => {
682682
// Interstitial ads must be loaded before they can be shown, so adding a listener
683683
const InterstitialAdListener = com.google.android.gms.ads.AdListener.extend({
684684
onAdLoaded: () => {
685-
firebase.admob.interstitialView.show();
685+
if (firebase.admob.interstitialView) {
686+
firebase.admob.interstitialView.show();
687+
}
686688
resolve();
687689
},
688690
onAdFailedToLoad: errorCode => {
689691
reject(errorCode);
690692
},
691693
onAdClosed: () => {
692-
firebase.admob.interstitialView.setAdListener(null);
693-
firebase.admob.interstitialView = null;
694+
if (firebase.admob.interstitialView) {
695+
firebase.admob.interstitialView.setAdListener(null);
696+
firebase.admob.interstitialView = null;
697+
}
694698
}
695699
});
696700
firebase.admob.interstitialView.setAdListener(new InterstitialAdListener());

0 commit comments

Comments
 (0)