Hello,
How can I put admob ads in a drupalgap android app?
Thanks

Comments

tyler.frankenstein’s picture

Status: Active » Postponed (maintainer needs more info)

I've never used admob ads, so I don't know for sure. But I bet the first step is to try placing them in a custom block...? http://drupalgap.org/node/169

Try that, and please report back your findings, along with your sample code.

coolman7’s picture

AdMob is Google's AdSense equivalent. There are bunch of Cordova AdMob plugins. But I don't know how to integrate them with drupalgap blocks.

$ cordova plugin search admob
com.admob.admobads - Phonegap, Cordova, Intel XDK AdMob plugin. Monetize your app with one javascript line. Android SDK v6.5, iOS SDK v7.0.0. Tappx support.
com.admob.admobplugin -
Admob SDK Plugin for phonegap and cordova ,support ios and android,support admob v1 and admob v2
project home:https://github.com/admob-google/admob-phonegap
com.admob.google - Google AdMob Ads plugin for Cordova, Phonegap, Ionic/Angular and Intel XDK. Monetize your app with one javascript line. Android SDK v6.5, iOS SDK v7.0.0. With support for tappx and auto-detect internet connection.
com.admob.plugin -
Google AdMob plugin for Cordova, Phonegap and Intel XDK ,support ios and android,support admob v1 and admob v2 ,Monetize your app with one javascript line.simple and easy to use api.

com.admob.pro - Powerful Ad Plugin for Google AdMob and DFP. Easy use, show mobile Ad with single line of JavaScript. Stable and up to date with latest SDK. Compatible with Cordova CLI, PhoneGap Build, Intel XDK/Crosswalk, Google ChromeApp, IBM Worklight.
com.ads.tappx - Tappx plugin for Cordova, Phonegap, Ionic/Angular and Intel XDK. Monetize your apps with the FREE ad exchange comunity. Supports Admob too.
com.blackpositive.cordova.plugin.admob - The most popular AdMob plugin for Cordova/PhoneGap, Intel XDK compatible. Support latest Google Play Services for Android, iOS and Windows Phone SDK.
com.cranberrygame.phonegap.plugin.ad.admob - Phonegap Admob plugin
com.cranberrygame.phonegap.plugin.ad.admob.overlay - moved to com.cranberrygame.phonegap.plugin.ad.admob
com.cranberrygame.phonegap.plugin.ad.admobadsfree - moved to com.cranberrygame.phonegap.plugin.ad.admob
com.google.admob -
Admob Plugin ,base on admob ios sdk 6.10 and android google play service sdk 4.5 ,support ios and android,support admob v1 and admob v2,support all admob banner and Interstitial
project home: https://sourceforge.net/projects/phonegap-admob/?source=directory
com.google.admobsdk - AdMob SDK for Android, iOS and WP8 only, as dependency of other plugins
com.google.admobsdk-googleplay - Not a plugin for javascript to call, it just add google-play-services.jar to project, used as dependency of other plugins. For AdMob plugin, use: com.google.cordova.admob
com.google.admobsdk-ios - Not a plugin for javascript to call, it just add AdMob SDK to project, as dependency of some plugins. For AdMob plugin, use: com.google.cordova.admob
com.google.admobsdk-wp - Not a plugin for javascript to call directly, it just add AdMob SDK to cordova project as dependency of some other plugins
com.google.cordova.admob - Powerful Ad Plugin for Google AdMob and DFP. Easy use, show mobile Ad with single line of JavaScript. Stable and up to date with latest SDK. Compatible with Cordova CLI, PhoneGap Build, Intel XDK/Crosswalk, Google ChromeApp, IBM Worklight.
com.google.cordova.admob-facebook - AdMob Mediation Adapter for Facebook Audience Network
com.google.cordova.admob-flurry - AdMob Mediation Adapter for Flurry Ads
com.google.cordova.admob-iad - AdMob Mediation Adapter for iAd
com.google.cordova.admob-inmobi - AdMob Mediation Adapter for InMobi
com.google.cordova.admob-mmedia - AdMob Mediation Adapter for Millennial Media
com.google.cordova.admob-mobfox - AdMob Mediation Adapter for MobFox
com.google.google-play-services -
Google play service Plugin of Admob ,base on admob ios sdk 6.10 and android google play service sdk 4.5 ,support ios and android,support all admob banner and Interstitial
project home:https://github.com/gooogleadmob/admob-phonegap

com.ios.libgoogleadmobads - iOS Google AdMob Ads library base dependency for other plugins
com.ludei.ads.android.admob - Android AdMob Ads implementation
com.ludei.ads.android.mopub.admob - Android MoPub AdMob Adapter
com.ludei.ads.ios.admob - iOS Ads AdMob implementation
com.ludei.ads.ios.mopub.admob - iOS AdMob adapter for MoPub
com.rjfun.cordova.facebookads - Cordova/PhoneGap Plugin for Facebook Audience Network Ads
com.rjfun.cordova.plugin.admob - The most popular AdMob plugin for Cordova/PhoneGap, Intel XDK compatible. Support latest Google Play Services for Android, iOS and Windows Phone SDK.
com.rjfun.cordova.plugin.qihu360ad - Add Qihu360Ad support to your cordova apps or games to earn revenue
org.google.admobplugin -
Google AdMob plugin for Cordova, Phonegap and Intel XDK ,support ios and android,support admob v1 and admob v2 ,Monetize your app with one javascript line.simple and easy to use api.

com.google.libgoogleadmobads - iOS Google AdMob Ads library base dependency for other plugins

tyler.frankenstein’s picture

All of that text isn't helpful. None of it looks like sample admob code. If you'd like proper assistance, we're going to need proper direction.

coolman7’s picture

There was no source code in my previous post. It only displays following command's output which displays admob plugins for cordova (phonegap):

$ cordova plugin search admob

If I can find document how can I use cordova (phonegap) plugins with drupalgap, I will try to do.

tyler.frankenstein’s picture

Installing the plugin is easy, and you should be done. I would imagine admob has snippet(s) of JavaScript that you would drop onto an HTML page to display the ad. No?

coolman7’s picture

I'll try and if I will be successful, I'll post the code here.
Thanks

coolman7’s picture

I found a workaround. It could be cleaner, but this seems to be working for me.

Add following plugin with this command:

cordova plugin add com.rjfun.cordova.plugin.admob

Add following code to www/index.html

<script>
    function onDocLoad() {
        if(( /(ipad|iphone|ipod|android|windows phone)/i.test(navigator.userAgent) )) {
            document.addEventListener('deviceready', initApp, false);
        } else {
            initApp();
        }
    }
    
    function initApp() {
        initAd();
        // display the banner at startup
        window.plugins.AdMob.createBannerView();
    }
    function initAd(){
        if ( window.plugins && window.plugins.AdMob ) {
    	    var ad_units = {
				ios : {
					banner: 'ca-app-pub-<your admob ad id>',
					interstitial: 'ca-app-pub-<your admob ad id>'
				},
				android : {
					banner: 'ca-app-pub-<your admob ad id>',
					interstitial: 'ca-app-pub-<your admob ad id>'
				},
				wp8 : {
					banner: 'ca-app-pub-<your admob ad id>',
					interstitial: 'ca-app-pub-<your admob ad id>'
				}
    	    };
    	    var admobid = "";
    	    if( /(android)/i.test(navigator.userAgent) ) {
    	    	admobid = ad_units.android;
    	    } else if(/(iphone|ipad)/i.test(navigator.userAgent)) {
    	    	admobid = ad_units.ios;
    	    } else {
    	    	admobid = ad_units.wp8;
    	    }
            window.plugins.AdMob.setOptions( {
                publisherId: admobid.banner,
                interstitialAdId: admobid.interstitial,
                bannerAtTop: false, // set to true, to put banner at top
                overlap: false, // set to true, to allow banner overlap webview
                offsetTopBar: false, // set to true to avoid ios7 status bar overlap
                isTesting: false, // receiving test ad
                autoShow: true // auto show interstitial ad when loaded
            });
            registerAdEvents();
            
        } else {
            alert( 'admob plugin not ready' );
        }
    }
	// optional, in case respond to events
    function registerAdEvents() {
    	document.addEventListener('onReceiveAd', function(){});
        document.addEventListener('onFailedToReceiveAd', function(data){});
        document.addEventListener('onPresentAd', function(){});
        document.addEventListener('onDismissAd', function(){ });
        document.addEventListener('onLeaveToAd', function(){ });
        document.addEventListener('onReceiveInterstitialAd', function(){ });
        document.addEventListener('onPresentInterstitialAd', function(){ });
        document.addEventListener('onDismissInterstitialAd', function(){ });
    }
    function onResize() {
        var msg = 'web view: ' + window.innerWidth + ' x ' + window.innerHeight;
        document.getElementById('sizeinfo').innerHTML = msg;
    }
    </script>

And change <body> tag of www/index.html to
<body onload="onDocLoad()" onresize="onResize()">

tyler.frankenstein’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Thanks for sharing this information.

coolman7’s picture

This code was working with SDK rc4 or rc5, but not working with newly release SDK 1.0. It displays undefined undefined at the bottom of every pages.

tyler.frankenstein’s picture

Since that is custom code, you'll have to step through it with dpm() or the console.log() and figure out what is going on.

coolman7’s picture

it looks like it is about theme. I deleted footer from settings.js, then it displays "undefinedundefined" at the end of every page.
Than I modified theme and deleted all footer settings from theme, now undefined disappeared.

JodyLee’s picture

Hi, I'm having trouble with this code and plugins to monetise apps with AdMob & DFP... I keep getting the alert - admob plugin not ready.

Is there something new I need to do?

And I'd rather use AdMobPro to use the other services too or manually add Admob and DFP SDKs if possible.

Can you help with this issue?

Thanks.