Closing AdMob ads after opening in Cordoba, for iOS

When I set the bannerView to hidden, it leaves a white box overlaying my app. The ad disappears, but the space it occupies is now blocked by a white box.

I am using XCode 4.5.2, Cordova 2.2 and Google AdMob Ads Sdk iOS 6.2.1

I am using this plugin https://github.com/ellemayo/phonegap-plugins-1/tree/master/iOS/AdMobPlugin

I am also using the code from this answer: How to switch admob view from MainViewController using Cordova

(void) hideAd: (NSMutableArray *) arguments
      withDict: (NSMutableDictionary *) options {
    CDVPluginResult * pluginResult;
    NSString * callbackId = [arguments pop];

    if (! self.bannerView) {
        // Try to prevent requestAd from being called without createBannerView first
        // being called.
        pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR
                                         messageAsString: @ "AdMobPlugin:"
                        @ "No ad view exists"];
        [self writeJavascript: [pluginResult toErrorCallbackString: callbackId]];
        return;
    }
    BOOL isHidden = (BOOL) [[options objectForKey: @ "isHidden"] boolValue];
    self.bannerView.hidden = isHidden;

    pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK];
    [self writeJavascript: [pluginResult toSuccessCallbackString: callbackId]];
}

I call it with this javascript:

  window.plugins.AdMob.hideAd ({
                                            'isHidden': true
                                            },
                                            function () {},
                                            function () {}
                                            );
+3


source to share





All Articles