corona SDK でWebViewを使用して、画面下部に広告を表示してみました。
まず、配信管理(SSP)には「AdStir」を利用することにしました。
AdStirは管理画面が直観的で使いやすいです。
スマートフォンゲーム向けのDSP「GameLogic」と連携したとこので
ゲームコンテンツの場合は収益面も期待できそう。
http://gamebiz.jp/?p=129233
実装はとっても簡単!
広告表示用のHTMLファイルを用意し、native.showWebPopup()で表示するだけです。
(※Android動作は未確認)
ad.html(広告表示用)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> <meta http-equiv="refresh" content="30" /> <title>ad</title> </head> <body bgcolor="#999999" style="margin:0; padding:0;"> <!-- // Adstirタグ ここから --> <script type="text/javascript"> var adstir_vars = { platform : "webview", ver : "4.0", app_id : "MEDIA-XXXXXXXX", ad_spot: 1, center : false }; </script> <script type="text/javascript" src="http://js.ad-stir.com/js/adstir.js?20130527"></script> <!-- // Adstirタグ ここまで--> </body> </html> |
main.lua
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
-- -- main.lua -- display.setStatusBar( display.HiddenStatusBar ) display.setDefault( "background", 0, 0, 0 ) local sampleText = display.newText( "AD Sample", 0, 0, native.systemFont, 16 ) sampleText.x = display.contentWidth * 0.5 sampleText.y = display.contentHeight * 0.5 -- 広告表示 local function urlHandler(event) local url = event.url if( string.find( url, "http:" ) ~= nil or string.find( url, "mailto:" ) ~= nil ) then print("url: ".. url) system.openURL(url) end return true end local url = "ad.html" local adoptions = { hasBackground=false, autoCancel=false, baseUrl=system.ResourceDirectory, urlRequest=urlHandler } native.showWebPopup( 0, display.contentHeight - 50, display.contentWidth, 50, url, adoptions ) |
ソースはこちら
ohwakana/corona-ad-sample
ちなみにAdstirの管理画面はこんな感じです。
AdStirのCPC広告と、AMoAd,nendも申請済み。
カスタムネットワークで独自広告の配信も追加してます。