Corona SDK上的Admob Intertitial仅显示一次

时间:2014-01-03 23:07:28

标签: lua admob corona

我已经建立了一点main.lua来测试一下adobs的广告,但我的插页式广告中有问题。

-- 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

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

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

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

你必须继续打电话给showAd(" interstitial")