Реклама не показывается, но почему?

Я разрабатываю приложение для Android, используя phonegap. Я успешно добавил проект библиотеки google-play-services. Теперь я хочу интегрировать AdMob для рекламных целей. Я выполнил следующие шаги https://developers.google.com/mobile-ads-sdk/docs/. Мой проект создан и запущен успешно, но реклама там не показывается.

Я добавил плагин AdMob Cordova и СЦЕНАРИЙ в index.html. Вот мой index.html

    <!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <!--<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="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
        <!--<link rel="stylesheet" type="text/css" href="css/index.css" />-->
        <!-- <link href="lib/ionic/css/ionic.css" rel="stylesheet"> -->
        <link href="css/app.css" rel="stylesheet">
        <!-- <link href="css/leaflet.css" rel="stylesheet">
        <link href="css/leaflet.draw.css" rel="stylesheet">
        <link href="css/nv.d3.css" rel="stylesheet"> -->
        <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
        <link href="css/ionic.app.css" rel="stylesheet">
        -->
        <style type="text/css">
          .css-form input.ng-invalid.ng-dirty {
            /*background-color: #FA787E;*/
              outline: none;
              box-shadow:0px 0px 7px #FA787E;
              border-color:#FA787E;
          }

          .css-form input.ng-valid.ng-dirty {
            /*background-color: #78FA89;*/
              outline: none;
              box-shadow:0px 0px 7px #78FA89;
              border-color:#78FA89;
          }


        </style>
        <!-- ionic/angularjs js -->
        <script src="js/leaflet.js"></script>
        <script src="js/d3.js"></script>
        <script src="js/nv.d3.js"></script>
        <script src="lib/ionic/js/ionic.bundle.js"></script>
        <script src="js/ng-cordova.js"></script>
        <script src="js/geolocation.js"></script>

        <script src="js/angularjs-nvd3-directives.js"></script>
        <script src="js/angular-cookies.js"></script>

        <script src="js/angular-resource.js"></script>
        <script src="js/angular-leaflet-directive.min.js"></script>
        <script src="js/leaflet.draw.js"></script>

    </head>
    <body ng-app="starter">
            <ion-nav-view animation="slide-left-right-ios7">
            </ion-nav-view>

        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="deviceinfo.js"></script>
        <script type="text/javascript" src="telephonenumber.js"></script>
        <script type="text/javascript" src="sharedprefs.js"></script>
        <!-- your app's js -->
        <script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script src="js/services.js"></script>
        <script src="js/controllers.js"></script>
        <script src="js/app.js"></script>
        <script type="text/javascript" src="js/geolib.js"></script>
        <script type="text/javascript" src="js/moment.min.js"></script>
        <script type="text/javascript">
        Date.prototype.deductHours= function(h){
            this.setHours(this.getHours()-h);
            return this;
        }
        Date.prototype.addHours= function(h){
            this.setHours(this.getHours()+h);
            return this;
        }
    </script>
    <script>
        function onDocLoad() {
                    initApp();                    
        }

        function initApp() {
            initAd();

        console.log("initApp is running");
            // display the banner at startup
            window.plugins.AdMob.createBannerView();
        }
        function initAd(){
            if ( window.plugins && window.plugins.AdMob ) {
                console.log("initAd is running");
                var ad_units = {
                    ios : {
                        banner: 'ca-app-pub-2899535788334936/6458250207',
                        interstitial: 'ca-app-pub-2899535788334936/3672907408'
                    },
                    android : {
                        banner: 'ca-app-pub-2899535788334936/6458250207',
                        interstitial: 'ca-app-pub-2899535788334936/3672907408'
                    }
                };
                var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;

                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' );
            }
        }
       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>
    </body>
</html>

Может ли кто-нибудь сказать мне, что на самом деле я пропустил здесь? Я думаю, что мой проект все равно не находит плагин. Но я также добавил плагин в config.xml. Тогда что не так? Ответьте, пожалуйста!!


person Community    schedule 26.08.2014    source источник


Ответы (3)


Нет необходимости добавлять отдельные SDK для обоих GCM and AdMob, сервисы Google Play содержат оба SDK, которые вы можете использовать. Используйте последнюю версию Android google play services, которая содержит оба пакета SDK.

person RajaReddy PolamReddy    schedule 26.08.2014
comment
Спасибо за Ваш ответ. На самом деле я настроил проект библиотеки google-play-services, а затем добавил плагин Admob (мой проект разрабатывается на PhoneGap) без Admob SDK. GCM работает хорошо, но плагин admob не работает. LogCat ничего не показывает для AdMob. На самом деле я следую этому github.com/floatinghotpot/cordova-plugin-admob. Я также добавил ‹plugin name=Admob value=com.my.admob.plugin.AdMob/› в config.xml. - person ; 26.08.2014
comment
Я слежу за github.com/floatinghotpot/cordova-plugin-admob, но я я не импортирую банку admob в свой проект (я удалил ‹dependency id=com.google.admobsdk-googleplay version=›=5.0.89/› из plluin.xml). Я использую AdMob.java и AdMob.js и добавляю необходимый скрипт в index.html. - person ; 26.08.2014
comment
Google обновил google play services lib со всеми SDK, поэтому вы должны использовать его для всех SDK, связанных с Google. если это решит вашу проблему, сделайте это ответом. - person RajaReddy PolamReddy; 26.08.2014
comment
Как я уже упоминал в своем предыдущем комментарии, я добавил сервисы google-play. Поэтому сейчас я не использую никакую другую библиотеку. Мой проект был построен и правильно запущен с помощью google-play-services. Я думаю, что мой плагин не называется правильно. - person ; 26.08.2014

Вы делаете по-старому, на самом деле, Google объявил обновленную библиотеку google_play_services, которая содержит в себе все ваши индивидуальные библиотеки. Так что не используйте отдельные библиотеки, просто обновите библиотеку google_play_service и вперед...!!!

person Pratik Dasa    schedule 26.08.2014

Хорошо, моя проблема решена. Проблема не была связана с конфигурацией google-play-services. Поэтому я не могу принять никакого ответа. Спасибо всем, кто мне помогает. По крайней мере, я был уверен, что не ошибся в настройках google-play-services и admob.

person Community    schedule 27.08.2014
comment
В чем была проблема? - person Nitzan Wilnai; 22.10.2014