谷歌播放Admob的整合与PhoneGap的 [英] Google Play Admob integration with Phonegap

查看:132
本文介绍了谷歌播放Admob的整合与PhoneGap的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在2014年加入谷歌Admob的到PhoneGap的应用程序(机器人)?

How do you add Google Admob to a phonegap app (android) in 2014?

我已经检查了网上很多例子如<一href="http://stackoverflow.com/questions/8029520/how-to-add-admob-advertising-in-my-android-application?rq=1">link1 链接2 链接3 <一href="http://stackoverflow.com/questions/22002424/admob-with-cordova-3-and-google-play-services">Link4.大多数链接,谷歌不久将去precated 的Andr​​oid 6.4.1的教程

I have checked many examples online e.g. link1 link2 Link3 Link4. Most link to Googles soon to be deprecated Android 6.4.1 tutorial.

除了特定的安卓或iOS的教程,我找不到任何说明如何实现最新的AdMob 的进入PhoneGap的一个跨平台的应用程序。我见过的InMobi但它看起来像你发布你的应用程序之前,你可以得到一个发布者ID为您的广告。

Apart from specific android or iOS tutorials, I cannot find any that demonstrate how to implement the latest admob into phonegap for a cross platform app. I have seen inmobi however it looks like you have to publish your app before you can get a publisher id for your adverts.

更新了Android简化说明  我收到了黑匣子的广告却没有别的,没有警报消息,没有广告

Update with Android simplified instructions I am getting the black box for the advert however nothing else, no alert messages, no advert

phonegap create myproject
cd mypproject
phonegap run android

关闭模拟器

1.Install the Google Play Services plugin:  cordova plugin add     https://github.com/MobileChromeApps/google-play-services.git  
2.Install this plugin:  cordova plugin add https://github.com/floatinghotpot/cordova-plugin-admob.git  

然后我领导交给index.js和onDeviceReady我说

Then I headed over to index.js and onDeviceReady I added

   onDeviceReady: function() {
     app.receivedEvent('deviceready');

if( window.plugins && window.plugins.AdMob ) {
    var admob_android_key = 'pub-6xxxxxxxxxxxxx';
    var am = window.plugins.AdMob;

    am.createBannerView( 
    {
    'publisherId': admob_android_key,
    'adSize': am.AD_SIZE.BANNER,
    'bannerAtTop': true
    }, 
    function() {
        am.requestAd(
            { 'isTesting':true }, 
            function(){
                am.showAd( true );
            }, 
            function(){ alert('failed to request ad'); }
        );
    }, 
    function(){ alert('failed to create banner view'); }
    );
    } else {
    alert('AdMob plugin not available/ready.');
    }

  }

添加到index.html的

Added to index.html

       <div>
            <button id='show-ad' onClick="if(window.plugins.AdMob){ window.AdMob.plugins.showAd(true); }">Show Ad</button>
            <button id='hide-ad' onClick="if(window.plugins.AdMob){ window.AdMob.plugins.showAd(false); }">Hide Ad</button>
        </div>

PhoneGap的运行Android

phonegap run android

推荐答案

这AdMob广告插件适用于谷歌播放SDK:<一href="https://github.com/floatinghotpot/cordova-plugin-admob">https://github.com/floatinghotpot/cordova-plugin-admob 。检查主文件夹和子文件夹中自述文件的详细信息。

This admob plugin works with google play sdk: https://github.com/floatinghotpot/cordova-plugin-admob . Check readmes in main folder AND in subfolders for details.

这篇关于谷歌播放Admob的整合与PhoneGap的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆