【发布时间】:2015-03-21 03:58:03
【问题描述】:
我在电晕论坛上发布了这个,但没有回应。一定有什么明显的我遗漏了,希望有人能提供帮助!
我开始集成 admobs,但似乎无法获得 adlistener 事件。
我有这个代码:
main.lua:
appID = "ca-app-pub-8278249997676996/7462506469"
ads = require("ads")
-- Create a text object to display ad status
statusText = display.newText( "ad status text", 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160
-- Set up ad listener.
function adListener( event )
statusText.text = "got an ad listener event!"
-- event table includes:
-- event.provider
-- event.isError (e.g. true/false )
local msg = event.response
-- just a quick debug message to check what response we got from the library
print("Message received from the ads library: ", msg)
if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = "Error Loading Ad " .. msg
statusText.x = display.contentWidth * 0.5
--showAd( "banner" )
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = "Successfully Loaded Ad : " .. msg
statusText.x = display.contentWidth * 0.5
end
end
-- Initialize the 'ads' library with the provider you wish to use.
if appID then
print("initialising admob")
ads.init( "admob", appID, adListener )
end
和
另一个文件.lua
statusText.text = "Let's show an ad please"
ads.show( "banner", {x=0, y=0} )
statusText.text 更改为“让我们显示一个广告请求”e,ads.show( 是下一行代码。但是 statusText.text 没有进一步更改,这意味着 adListener 没有被调用。也没有显示广告。
在我的构建设置中:
androidPermissions =
{
"android.permission.READ_PHONE_STATE",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.VIBRATE",
"android.permission.INTERNET"
},
plugins =
{
-- key is the name passed to Lua's 'require()'
["CoronaProvider.ads.admob"] =
{
-- required
publisherId = "com.sportspunter",
},
},
欢迎提出任何建议!
谢谢
【问题讨论】: