Admobで広告ユニットを作成し、プロジェクトに設定をしたのですがまったく表示されず困っています。行った作業は下記の通りです。
- Admobで広告ユニットを作成し、広告ユニットIDを取得
- Admobのプラグインをインストール
$ cordova plugin add cordova-plugin-admobpro
- プロジェクトファイル内のjsファイルに下記のコードを記述
var app = { // Application Constructor initialize: function() { this.bindEvents(); }, // Bind Event Listeners // // Bind any events that are required on startup. Common events are: // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, // deviceready Event Handler // // The scope of 'this' is the event. In order to call the 'receivedEvent' // function, we must explicitly call 'app.receivedEvent(...);' onDeviceReady: function() { app.receivedEvent('deviceready'); }, // Update DOM on a Received Event receivedEvent: function(id) { var parentElement = document.getElementById(id); var listeningElement = parentElement.querySelector('.listening'); var receivedElement = parentElement.querySelector('.received'); listeningElement.setAttribute('style', 'display:none;'); receivedElement.setAttribute('style', 'display:block;'); console.log('Received Event: ' + id); } }; var admobid = {}; // select the right Ad Id according to platform if( /(android)/i.test(navigator.userAgent) ) { admobid = { // for Android banner: 'ca-app-pub-xxxxxxxxxxxxxxxxx' }; } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { admobid = { // for iOS banner: 'ca-app-pub-xxxxxxxxxxxxxxxxx' }; } else { admobid = { // for Windows Phone banner: 'ca-app-pub-xxxxxxxxxxxxxxxxx' }; } if(AdMob) AdMob.createBanner( { adId: admobid.banner, position: AdMob.AD_POSITION.BOTTOM_CENTER, autoShow: true } ); app.initialize();
以上です。
ご教授頂けますと幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。