Phonegap cordova-plugin-admob-simple 无法显示任何广告

Phonegap cordova-plugin-admob-simple Cannot Get Any Ads to Show

我束手无策。我无法让这个插件工作。我已经完全按照 PhoneGap Cordova Admob plugin not working 中的说明进行操作(当您向下滚动到引用此插件的答案时。)我正在使用最新的 phonegap cli 运行 phonegap 服务。我什至创建了一个空页面 (debug.html) 以确保没有其他代码干扰。

到目前为止我做了什么:

我总是收到 'admob plugin not ready' 的警报。

我尝试将行 "window.plugins.AdMob" 更改为 AdMob、plugins.Admob、navigator.Admob、window.Admob。我仍然收到此错误。

当我注释掉该检查 ("if ( window.plugins && window.plugins.AdMob ) {"),并强制它成为 运行 代码时,没有任何反应。我在命令行上没有收到任何错误,在任何可以调试的地方都没有收到任何错误。

这是我的代码:

<!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>Debug Page</title>
    <style>
        .bodyStyle{
            font-size: 32px;
        }
    </style>
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script> 

</head>
<body >
<script>
    function onDeviceReady() {
        console.log("DEVICE READY");
//initialize the goodies

        if ( window.plugins && window.plugins.AdMob ) {
            var ad_units = {
                ios : {
                    banner: 'ca-app-pub-1631005955280974/1599263468',       //PUT ADMOB ADCODE HERE
                    interstitial: 'ca-app-pub-1631005955280974/6029463060'  //PUT ADMOB ADCODE HERE
                },
                android : {
                    banner: 'ca-app-pub-1631005955280974/1599263468',       //PUT ADMOB ADCODE HERE
                    interstitial: 'ca-app-pub-1631005955280974/6029463060'  //PUT ADMOB ADCODE HERE
                }
            };
            var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;

            window.plugins.AdMob.setOptions( {
                publisherId: admobid.banner,
                interstitialAdId: admobid.interstitial,
                adSize: window.plugins.AdMob.AD_SIZE.SMART_BANNER,  //use SMART_BANNER, BANNER, IAB_MRECT, IAB_BANNER, IAB_LEADERBOARD
                bannerAtTop: false, // set to true, to put banner at top
                overlap: true, // banner will overlap webview 
                offsetTopBar: false, // set to true to avoid ios7 status bar overlap
                isTesting: true, // receiving test ad
                autoShow: true // auto show interstitial ad when loaded
            });

            registerAdEvents();
            window.plugins.AdMob.createInterstitialView();  //get the interstitials ready to be shown
            window.plugins.AdMob.requestInterstitialAd();

        } else {
            alert( 'admob plugin not ready' );
        }

//functions to allow you to know when ads are shown, etc.
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(){
            window.plugins.AdMob.createInterstitialView();          //REMOVE THESE 2 LINES IF USING AUTOSHOW
            window.plugins.AdMob.requestInterstitialAd();           //get the next one ready only after the current one is closed
        });
    }
    function showBannerFunc(){
    AdMob.createBannerView();
}
//display the interstitial
function showInterstitialFunc(){
    AdMob.showInterstitialAd();
}

    document.addEventListener("deviceready", onDeviceReady, false);
</script>
<button type='button' onclick='showBannerFunc();'>SHOW BANNER</button>
<br/><br/>
<button type='button' onclick='showInterstitialFunc();'>SHOW INTER</button>
</body>
</html>

它在主要 config.xml 作为

<plugin name="cordova-plugin-admob-simple" spec="~3.3.3" />

拜托,我已经在这里工作了 2 个多星期,我已经用谷歌搜索了所有可能的内容。我必须阅读至少 100 页以寻求帮助,但不知道还能尝试什么。我发现的一切,我都试过无济于事。甚至没有什么不同,它只是不显示任何类型的广告。横幅或其他。即使我点击按钮。请帮帮我。谢谢。

好吧,我终于明白了。我正在使用 Phonegap 服务。这不支持插件,或者至少不支持第 3 方插件。你必须使用 Phonegap 运行。

我目前处于您 2 周前所处的阶段。我已经为 Admob 测试了不同的插件,但没有显示任何广告。 不幸的是,即使我正在生成一个 apk 文件并 运行 它在移动设备上也没有任何反应。 我已经使用了您的代码,但按下 "show Banner" 按钮时没有显示任何内容。

我使用了虚拟 ID (ca-app-pub-3940256099942544/6300978111) 以及我自己的 ID。

或许你可以看看我的问题,给个建议: Using AdMob and Cordova - ad is not displayed

谢谢,

彼得