2012年10月19日金曜日
corona SDKにmediba adの広告を表示させる方法
main.luaに以下のコードを書きます。
■■■■■■■■■■■■■■■■■■■■■■■■■■■■
function webListener(event)
local url = event.url
if string.find( url, "http" ) ~= nil or string.find( url, "mailto:" ) ~= nil then
webViewTest:stop()
webViewTest:back()
native.showAlert( "確認", event.url, { "OK" } )
system.openURL(event.url)
end
end
webViewTest = native.newWebView( 0, 0, 320, 50, webListener )
webViewTest:request( "ad.html", system.ResourceDirectory )
■■■■■■■■■■■■■■■■■■■■■■■■■■■■
ad.htmlというファイルを作成し、以下のhtmlを書きます。
■■■■■■■■■■■■■■■■■■■■■■■■■■■■
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1 user-scalable=no" />
<title>Sample HTML</title>
<script type="text/javascript">
var medibaadset = {
ads : [ {
auid : '広告コード',
addivid : 'adcon1',
displayType : 1,
adspace : true
} ]
};
</script>
<script type="text/javascript" src="http://adc.medibaad.com/public/js/medibaad-script-client-head.js"></script>
</head>
<body>
<div id="adcon1"></div>
</body>
</html>
■■■■■■■■■■■■■■■■■■■■■■■■■■■■
auidを自分の広告コードに変えたら完成です。
ちなみにwebPopup()でも実装可能です。
実装は自己責任でお願いします。
参考文献:
http://medibaad.com/developer/support/browser.html
ラベル:
corona SDK,
アプリ開発
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿