Software Archive
Read-only legacy content
17061 Discussions

Remove admob banner problems?

John_E_2
New Contributor I
884 Views

Hello!

iam using this script to show my admob but i dont want the banner to show only the interstitial.

now both shows up, can i remove the banner and only show the interstitial? 

can someone help me?

thanks:)

<script src='cordova.js'></script>

    <script type="text/javascript">

        

       var onDeviceReady=function(){

           navigator.splashscreen.hide();

           initAdMob();

           showAdMobInterstitial();

           showAdMobBanner();

        };

        document.addEventListener("deviceready",onDeviceReady,false);

       

       function initAdMob(){

           if ( window.plugins && window.plugins.AdMob ) {

               var admob_key_banner = "xx";

               var admob_key_interstitial = "xx";

               window.plugins.AdMob.setOptions( {

                   publisherId: admob_key_banner,

                   bannerAtTop: true, // set to true, to put banner at top

                   overlap: false, // set to true, to allow banner overlap webview

                   offsetTopBar: true, // set to true to avoid ios7 status bar overlap                    

                   interstitialAdId: admob_key_interstitial,

                   autoShow: true, // autoshow intertitial Ad

                   isTesting: false // receiving test ad

               });

           } else {

               alert("AdMob plugin not ready");

           }

       }

       

       function showAdMobBanner(){

           window.plugins.AdMob.createBannerView();

       }

       

       function showAdMobInterstitial(){

           window.plugins.AdMob.createInterstitialView();

       }

       

    </script>

 
0 Kudos
5 Replies
Elroy_A_Intel
Employee
884 Views

I recommend removing all references to properties and methods including "banner" in the name. 

0 Kudos
John_E_2
New Contributor I
884 Views

thanks for your replay.

function destroyAdMobBanner(){

worked too.
0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
884 Views

do you build this function (destroyAdMobBanner) or it exists in the plugin?

0 Kudos
John_E_2
New Contributor I
884 Views

i changed this line in the plugin:

  }

       

       function showAdMobBanner(){

           window.plugins.AdMob.createBannerView();

       }

       

       function showAdMobInterstitial(){

           window.plugins.AdMob.createInterstitialView();

       }

to this: 
 

       }

       

       function destroyAdMobBanner(){

           window.plugins.AdMob.createBannerView();

       }

       

       function showAdMobInterstitial(){

           window.plugins.AdMob.createInterstitialView();

       }

Here is the whole code without the admob banner, only interstitial:

 

intel xdk plugin---------->com.rjfun.cordova.plugin.admob. And check the Plugin is located in the Apache Cordova Plugins Registry

 

 

 

 

<script src='cordova.js'></script>

    <script type="text/javascript">

        

       var onDeviceReady=function(){

           navigator.splashscreen.hide();

           initAdMob();

           showAdMobInterstitial();

           showAdMobBanner();

           

        };

        document.addEventListener("deviceready",onDeviceReady,false);

       

       function initAdMob(){

           if ( window.plugins && window.plugins.AdMob ) {

               var admob_key_banner = "yourkey";

               var admob_key_interstitial = "yourkey";

               window.plugins.AdMob.setOptions( {

                   publisherId: admob_key_banner,

                   bannerAtTop: true, // set to true, to put banner at top

                   overlap: false, // set to true, to allow banner overlap webview

                   offsetTopBar: true, // set to true to avoid ios7 status bar overlap                    

                   interstitialAdId: admob_key_interstitial,

                   autoShow: true, // autoshow intertitial Ad

                   isTesting: false // receiving test ad

               });

           } else {

               alert("AdMob plugin not ready");

           }

       }

       

       function destroyAdMobBanner(){

           window.plugins.AdMob.createBannerView();

       }

       

       function showAdMobInterstitial(){

           window.plugins.AdMob.createInterstitialView();

       }

       

    </script>  

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
884 Views

@John> thank you

0 Kudos
Reply