【问题标题】:Ad Mob Interstitial on CoronaSDK Show itself only one timeCorona SDK 上的 Admob 插页式广告仅展示一次
【发布时间】:2014-01-21 18:06:23
【问题描述】:

我构建了一个小main.lua 来测试 admob 的广告,但我的插页式 admob 有问题。

-- The name of the ad provider.
local provider = "admob"

-- Your application ID
local appID = "ca-app-pub-7171907831713303/2674724079"

-- Load Corona 'ads' library
local ads = require "ads"

--------------------------------------------------------------------------------
-- Setup ad provider
--------------------------------------------------------------------------------

-- Create a text object to display ad status
local statusText = display.newText( "", 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
 statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160

local showAd

 -- Set up ad listener.
 local function adListener( 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"
    statusText.x = display.contentWidth * 0.5

    showAd( "banner" )
else
    statusText:setTextColor( 0, 255, 0 )
    statusText.text = "Successfully Loaded Ad"
    statusText.x = display.contentWidth * 0.5
end
   end

 -- Initialize the 'ads' library with the provider you wish to use.
if appID then
ads.init( provider, appID, adListener )
  end

  --------------------------------------------------------------------------------
 -- UI
  --------------------------------------------------------------------------------

 -- initial variables
  local sysModel = system.getInfo("model")
  local sysEnv = system.getInfo("environment")

 -- create a background for the app
  local backgroundImg = display.newImageRect( "space.png", display.contentWidth,  display.contentHeight )
 backgroundImg:setReferencePoint( display.TopLeftReferencePoint )
  backgroundImg.x, backgroundImg.y = 0, 0
  statusText:toFront()

  -- Shows a specific type of ad
   showAd = function( adType )
local adX, adY = display.screenOriginX, display.screenOriginY
statusText.text = ""
ads.show( adType, { x=adX, y=adY } )
  end

 -- if on simulator, let user know they must build for device
 if sysEnv == "simulator" then
local font, size = native.systemFontBold, 22
local warningText = display.newText( "Please build for device or Xcode simulator     to test this sample.", 0, 0, 290, 300, font, size )
warningText:setTextColor( 255 )
warningText:setReferencePoint( display.CenterReferencePoint )
warningText.x, warningText.y = display.contentWidth * 0.5, display.contentHeight * 0.5
else
-- start with banner ad
showAd( "interstitial" )
 end

我已经在我的设备上测试了这个应用程序,当我第一次启动它时,一切都运行良好。但在那之后没有显示任何广告。我应该等多久才能看到广告?

可能是什么问题?

【问题讨论】:

  • 我也有这个问题。即使关闭它,我也会开始横幅广告。横幅广告只显示一次,不再显示。
  • 您使用的是哪个 admob 插件?有 admob-v1 和 admob-v2 使用 v2 插件。

标签: lua admob coronasdk


【解决方案1】:

这是因为你只调用了一次。您需要在循环中调用它,延迟或任何事件不断发生。

你必须继续调用 showAd("interstitial")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    相关资源
    最近更新 更多