PhoneGap 构建 admob
PhoneGap Build admob
我在构建 phonegap 时遇到问题,admob 不显示...我该如何显示它?
这是我的js文件
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="js/createjs-2013.09.25.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/sounds.js"></script>
<script type="text/javascript" src="js/admob.js"></script>
这是我启动游戏的主要功能。
<script>
$(document).ready(function(){
var oMain = new CMain({
min_reel_loop:2,
reel_delay: 6,
time_show_win:2000,
time_show_all_wins: 2000,
money:3000
});
$(oMain).on("game_start", function(evt) {
//alert("game_start");
});
$(oMain).on("end_bet", function(evt,iMoney,iBetWin) {
//alert("iMoney: "+iMoney + " Win:"+iBetWin);
});
$(oMain).on("restart", function(evt) {
//alert("restart");
});
});
</script>
检查 documentation of the AdMob plugin,更具体地说,您需要此功能来使用您的自定义设置创建横幅:
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
});
我链接的示例 index.html 可以使用并根据您的特定设置展示广告。
回应您关于如何在游戏开始时显示广告的评论,并在此处使用插件:https://github.com/appfeel/admob-google-cordova您应该这样做:
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
// Set AdMobAds options:
admob.setOptions({
publisherId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB", // Required
interstitialAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII", // Optional
});
// Start showing banners (atomatic when autoShowBanner is set to true)
admob.createBannerView();
}
document.addEventListener("deviceready", onDeviceReady, false);
我在构建 phonegap 时遇到问题,admob 不显示...我该如何显示它?
这是我的js文件
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="js/createjs-2013.09.25.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/sounds.js"></script>
<script type="text/javascript" src="js/admob.js"></script>
这是我启动游戏的主要功能。
<script>
$(document).ready(function(){
var oMain = new CMain({
min_reel_loop:2,
reel_delay: 6,
time_show_win:2000,
time_show_all_wins: 2000,
money:3000
});
$(oMain).on("game_start", function(evt) {
//alert("game_start");
});
$(oMain).on("end_bet", function(evt,iMoney,iBetWin) {
//alert("iMoney: "+iMoney + " Win:"+iBetWin);
});
$(oMain).on("restart", function(evt) {
//alert("restart");
});
});
</script>
检查 documentation of the AdMob plugin,更具体地说,您需要此功能来使用您的自定义设置创建横幅:
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
});
我链接的示例 index.html 可以使用并根据您的特定设置展示广告。
回应您关于如何在游戏开始时显示广告的评论,并在此处使用插件:https://github.com/appfeel/admob-google-cordova您应该这样做:
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
// Set AdMobAds options:
admob.setOptions({
publisherId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB", // Required
interstitialAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII", // Optional
});
// Start showing banners (atomatic when autoShowBanner is set to true)
admob.createBannerView();
}
document.addEventListener("deviceready", onDeviceReady, false);