admob-google / admob-cordova

Google AdMob plugin for Cordova, Phonegap and Intel XDK ,support ios and android,support admob v1 and admob v2 ,Monetize your html5 app with one javascript line.api is easy to use.
65 stars 50 forks source link

On test page, only showBannerAbsolute shows ad #8

Closed jamminjames closed 8 years ago

jamminjames commented 9 years ago

I have version 3.0.0 installed in an app created via Phonegap Build. (Version 5.0.1 is crashing my app -- see other issue -- so I'm going with this earlier version.)

Using the html configuration for the test page, only the showBannerAbsolute link (4th one) produces an ad. Nothing happens with the other links at all, except for the hideBanner link, which does hide the banner ad. I have the html set up as shown in the test page: `

  • load Interstitial
  •     <br/>
        <li><a href="javascript:showInterstitial();">show Interstitial</a></li>
        <br/>
        <li><a href="javascript:showTestBanner();">show test banner</a></li>
        <br/>
        <li><a href="javascript:admob.showBannerAbsolute(admob.BannerSize.BANNER,0,70);">show banner absolute</a></li>
        <br/>
        <li><a href="javascript:admob.hideBanner()">hide banner</a></li>
    </lu>`

    AdmobPlugin.js loaded with the app, and I am calling the script that is shown in the example test page via a 'pagecreate' function, since that is what jquery.mobile prefers.

    I can't figure out why the other ad links aren't working. Any help would be appreciated. Thanks!

    admob-google commented 9 years ago

    showTestBanner,showInterstitial is defined in html page,have you add there to your page?Just tell me your application crashes there is no use, I need more information, including systems, operating procedures,crash logs, etc

    jamminjames commented 9 years ago

    Yes, that's the code from the html page I quoted above. It's taken exactly from the example index.html page. This app is only android so far, built with Phonegap. I don't have any crash logs, since this happens on an Android device, it does not crash while testing on a browser. When it crashes, it just gives a generic error message, I forget exactly what, something to the effect that 'this app had to close.' Operating procedures? Not sure what you mean...

    admob-google commented 9 years ago

    have you try the demo app? can you send your apk that crash to me gooogleadmob@gmail.com to run ?

    admob-google commented 9 years ago
    
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <meta name="msapplication-tap-highlight" content="no" />
        <title>banner demo</title>
        <style>
            .bodyStyle{
                font-size: 32px;
            }
        </style>
    </head>
    <body >
    <div class="bodyStyle">
        <h1>demo</h1>
        <lu>
            <li><a href="javascript:admob.cacheInterstitial();">load Interstitial</a></li>
            <br/>
            <li><a href="javascript:showInterstitial();">show Interstitial</a></li>
            <br/>
            <li><a href="javascript:showTestBanner();">show test banner</a></li>
            <br/>
            <li><a href="javascript:admob.showBannerAbsolute(admob.BannerSize.BANNER,0,70);">show banner absolute</a></li>
            <br/>
            <li><a href="javascript:admob.hideBanner()">hide banner</a></li>
        </lu>
    
    </div>
     <div id="alertdiv"/>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript">
    function showTestBanner(){
            var admobParam=new  admob.Params();
            //admobParam.extra={'keyword':"admob phonegame"};
            //admobParam.isForChild=true;
            admobParam.isTesting=true;
            admob.showBanner(admob.BannerSize.BANNER,admob.Position.TOP_CENTER,admobParam);
    }
        function showInterstitial(){
            admob.isInterstitialReady(function(isReady){
                if(isReady){
                    admob.showInterstitial();
                }
            });
        }
        function onInterstitialReceive (message) {
            alert(message.type+" ,you can show it now");
            //admob.showInterstitial();//show it when received
        }
        function onReceiveFail (message) {
            var msg=admob.Error[message.data];
            if(msg==undefined){
               msg=message.data;
            }
            document.getElementById("alertdiv").innerHTML="load fail: "+message.type+"  "+msg;
        }
        function onDeviceReady() {
            admob.initAdmob("banner ID "," interstitial ID");
            document.addEventListener(admob.Event.onInterstitialReceive, onInterstitialReceive, false);
            document.addEventListener(admob.Event.onInterstitialFailedReceive,onReceiveFail, false);
            document.addEventListener(admob.Event.onBannerFailedReceive,onReceiveFail, false);
        }
    
        document.addEventListener('deviceready',onDeviceReady, false);
    </script>
    </body>
    </html>
    
    admob-google commented 9 years ago
    cordova create demo com.admob.demo demo
    npm install admob
    cordova plugin add admob

    copy code to html , set banner ID and interstitial ID

    cordova platform add android
    cordova run android
    admob-google commented 9 years ago

    phonegap plugin version 5.0.3

    admob-google commented 8 years ago

    fixed,enjoy it