Software Archive
Read-only legacy content
17061 Discussions

Intel XDK AdMob Problem

Adam_t_1
Beginner
342 Views

Hi i have a problem with AdMob. I can´t add AdMob to my apk. I try everything. pleas help me :/

 

0 Kudos
3 Replies
Anusha_M_Intel1
Employee
342 Views

Hi Adam, 

What exactly is the issue with not being able to add it? Have you selected the plugin from the projects tab?

We have a admob sample called 'Hello Admob' that ships with the XDK for you to refer if you are having any code related issues. 

You can create the same within XDK or here is the link to its Git repo: https://github.com/gomobile/sample-hello-admob

0 Kudos
Smith__J
Beginner
342 Views

Anusha, the link you gave is over the heads of coding newbies. Which folder do you look in to find the answers? gitignore? json? Some simple copy and paste code would be nice, or, to have the AdMob template simply work without a lot of re-coding.

"removed AD-UNIT-ID from index.html" OK, so what does that mean to someone who can't get AdMob to work on an app they have already created? What code does it need, and where? The header, the body? I am at the point, I need to abandon XDK, and do something else if I want AdMob to work.

0 Kudos
Anusha_M_Intel1
Employee
342 Views

All the code you need is in: www/index.html

https://github.com/gomobile/sample-hello-admob/blob/master/www/index.html

function initAdMob(){
            if ( window.plugins && window.plugins.AdMob ) {
                //Login to https://apps.admob.com to get AD-UNIT-ID
                var admob_key_banner = "ADD_YOUR_AD-UNIT-ID_HERE"; //Banner Ads 
                var admob_key_interstitial = "ADD_YOUR_AD-UNIT-ID_HERE"; //Interstitial Ads
                window.plugins.AdMob.setOptions( {
                    publisherId: admob_key_banner,
                    bannerAtTop: false, // 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();
        }
        

Add initAdMob() to onDeviceReady function. Replace "ADD_YOUR_AD-UNIT-ID_HERE" with your Unit ID taken from https://www.google.com/admob/. Here you will create a profile for you app and retrieve Unit IDs for interstitial and banner ads. Replace it in the code. You should definitely try creating this app from within the XDK. So you can see how it works. 

Go to start new project -> Samples and Demos -> General -> HTML5+Cordova -> Hello Admob. I have attached a screenshot for your reference. 

0 Kudos
Reply