【问题标题】:Corona AdMob Integration, why no AdListener event?Corona AdMob 集成,为什么没有 AdListener 事件?
【发布时间】: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",
},
},

欢迎提出任何建议!

谢谢

【问题讨论】:

    标签: lua admob coronasdk


    【解决方案1】:

    您在 build.settings 文件的插件设置中更改了发布者 ID。试试这个:

    publisherId = "com.coronalabs",
    

    【讨论】:

      【解决方案2】:

      看起来您已经正确编码了所有内容,但我不是 100% 我知道正确的答案。我唯一能想到的就是你需要redeclaremain.lua中的代码anotherfile.lua。可能变量没有正确声明,所以它们没有被转移。

      另外,我很确定广告不会显示在模拟器上,因此请确保为设备构建。

      您的build.settings 看起来不错。

      希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-12
        • 1970-01-01
        • 1970-01-01
        • 2010-12-12
        • 1970-01-01
        • 2016-10-05
        相关资源
        最近更新 更多