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

Commit 925892b

Browse files
EddyVerbruggeneddyverbruggen
authored andcommitted
iOS crashes when AdMob is not enabled #294
1 parent 8af7d77 commit 925892b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

firebase.ios.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function prepAppDelegate() {
296296

297297
firebase._addObserver(UIApplicationDidFinishLaunchingNotification, function (appNotification) {
298298
// guarded this with a preference so the popup "this app wants to send notifications"
299-
// is not shown until the dev intentially wired a listener (see other usages of _registerForRemoteNotifications())
299+
// is not shown until the dev intentionally wired a listener (see other usages of _registerForRemoteNotifications())
300300
if (applicationSettings.getBoolean("registered", false)) {
301301
firebase._registerForRemoteNotifications();
302302
}
@@ -557,6 +557,11 @@ firebase.analytics.setUserProperty = function (arg) {
557557
firebase.admob.showBanner = function (arg) {
558558
return new Promise(function (resolve, reject) {
559559
try {
560+
if (typeof(GADRequest) === "undefined") {
561+
reject("Uncomment AdMob in the plugin's Podfile first");
562+
return;
563+
}
564+
560565
if (firebase.admob.adView !== null && firebase.admob.adView !== undefined) {
561566
firebase.admob.adView.removeFromSuperview();
562567
firebase.admob.adView = null;
@@ -615,6 +620,11 @@ firebase.admob.showBanner = function (arg) {
615620
firebase.admob.showInterstitial = function (arg) {
616621
return new Promise(function (resolve, reject) {
617622
try {
623+
if (typeof(GADRequest) === "undefined") {
624+
reject("Uncomment AdMob in the plugin's Podfile first");
625+
return;
626+
}
627+
618628
var settings = firebase.merge(arg, firebase.admob.defaults);
619629
firebase.admob.interstitialView = GADInterstitial.alloc().initWithAdUnitID(settings.iosInterstitialId);
620630

@@ -1776,7 +1786,9 @@ var GADBannerViewDelegateImpl = (function (_super) {
17761786
GADBannerViewDelegateImpl.prototype.interstitialDidFailToReceiveAdWithError = function (ad, error) {
17771787
this._callback(ad, error);
17781788
};
1779-
GADBannerViewDelegateImpl.ObjCProtocols = [GADInterstitialDelegate];
1789+
if (typeof(GADInterstitialDelegate) !== "undefined") {
1790+
GADBannerViewDelegateImpl.ObjCProtocols = [GADInterstitialDelegate];
1791+
}
17801792
return GADBannerViewDelegateImpl;
17811793
})(NSObject);
17821794

0 commit comments

Comments
 (0)