###前提・実現したいこと
monacaでアプリ作っていて、cordova-admob-pro(公式のサンプルアプリで使用されているのと同じプラグイン)を使ってadmobの動画リワードを載せようとしています。
#エラーの詳細
バナーの広告はできたのですが、動画リワードの広告の読込みでエラーが出ます。
error:9, reason: No ad return from any ad server.,adNetwork:AdMob, adType:rewardvideo, adEvent:onAdFailload ```動画リワードのリリース前テストができないようになっているのか、 monaca公式のサンプルアプリではbanner, interstatialしか例がないので、動画リワード用のメソッドには対応していないのでしょうか...? 何か解決方法や案、実践例(失敗例でも)あったら教えてもらえたらありがたいです。
var admobid = {};
if (/(android)/i.test(navigator.userAgent)){
console.log('Android');
admobid = { // for Android
banner: 'ca-app-pub-',
rewardvideo: 'ca-app-pub-',
};
} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)){
admobid = { // for iOS
banner: 'ca-app-pub-',
rewardvideo: 'ca-app-pub-',
};
} else {
admobid = { // for Windows Phone
banner: 'ca-app-pub-*********',
};
}
function createSelectedBanner(){
if(AdMob) AdMob.createBanner({
adId: admobid.banner,
overlap: $('#overlap').is(':checked'),
offsetTopBar: $('#offsetTopBar').is(':checked'),
adSize: $('#adSize').val(),
position: $('#adPosition').val(),
});
}
function showBannerAtPosition(){
if(AdMob) AdMob.showBanner( $('#adPosition').val() );
}
function onDeviceReady() {
if (! AdMob) { alert( 'admob plugin not ready' ); return; }
initAd();
// display a banner at startup
createSelectedBanner();
}
function initAd(){
AdMob.getAdSettings(function(info){
console.log('adId: ' + info.adId + '\n' + 'adTrackingEnabled: ' + info.adTrackingEnabled);
}, function(){
console.log('failed to get user ad settings');
});
AdMob.setOptions({
// adSize: 'SMART_BANNER',
position: AdMob.AD_POSITION.BOTTOM_CENTER,
isTesting: true, // set to true, to receiving test ad for testing purpose
bgColor: 'black', // color name, or '#RRGGBB'
// autoShow: true // auto show interstitial ad when loaded, set to false if prepare/show
// offsetTopBar: false, // avoid overlapped by status bar, for iOS7+
});
// new events, with variable to differentiate: adNetwork, adType, adEvent
$(document).on('onAdFailLoad', function(e){
// when jquery used, it will hijack the event, so we have to get data from original event
if(typeof e.originalEvent !== 'undefined') e = e.originalEvent;
var data = e.detail || e.data || e;
alert('error: ' + data.error +
', reason: ' + data.reason +
', adNetwork:' + data.adNetwork +
', adType:' + data.adType +
', adEvent:' + data.adEvent); // adType: 'banner', 'interstitial', etc.
});
// test rewarded video ad var videoReady = false; $('#game').click()(prepare()); //#gameはhtmlファイルに設定した function prepare() { videoReady = false; AdMob.prepareRewardVideoAd({ adId: admobid.rewardvideo, autoShow:true, isTesting: true }); } $('#checkvideo').click(function(){ if(videoReady) { AdMob.showRewardVideoAd(); } });
// 広告を見た際のretryボタンを押せるようにする処理
var retryb = document.getElementById('retryb');
document.addEventListener('onAdLeaveApp', function(data){ if(data.adType == 'rewardvideo') { retryb.className = "btn"; }
});
document.addEventListener('onAdLoaded', function(data){ if(data.adType == 'rewardvideo') { videoReady = true; }
});
document.addEventListener('onAdFailLoad', function(data){
if(data.adType == 'rewardvideo') {
videoReady = false;
prepare(); // prepare again for next ad
}
});
document.addEventListener('onAdDismiss', function(data){
if(data.adType == 'rewardvideo') prepare(); // prepare again for next ad
retryb.className = "btn";
});
// test case for #256, https://github.com/floatinghotpot/cordova-admob-pro/issues/256 $(document).on('backbutton', function(){ if(window.confirm('Are you sure to quit?')) navigator.app.exitApp(); }); // test case #283, https://github.com/floatinghotpot/cordova-admob-pro/issues/283 $(document).on('resume', function(){ AdMob.showInterstitial(); });
}
// test the webview resized properly
$(window).resize(function(){
$('#textinfo').html('web view: ' + $(window).width() + " x " + $(window).height());
});
$(document).ready(function(){
// on mobile device, we must wait the 'deviceready' event fired by cordova
if(/(ipad|iphone|ipod|android|windows phone)/i.test(navigator.userAgent)) {
document.addEventListener('deviceready', onDeviceReady, false);
} else {
onDeviceReady();
}
});
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/23 08:00
2017/10/21 17:05 編集