Implementing vungle in corona sdk

565 views Asked by At

How do i implement vungle in to corona sdk for only one scene. I followed the docs on corona site to implement vungle to my game. I implemented in only one scene of my game but it shows in every scene randomly, my question is how do i keep the vungle in only one scene.

I use also inmobi ads in game.

Here is the code i used.

I used this code in only one scene of my game.

 local provider = "vungle"
 local appId = "vungleTest"
 local ads = require "ads"

 local function adListener( event )
    if event.type == "adStart" and event.isError then
        -- cached video ad not available for display
    end
 end

 ads.init( provider, appId, adListener )
 local wasAdShown = ads.show( "interstitial", { isAnimated = false, isBackButtonEnabled = true } )
2

There are 2 answers

0
Jordan Schuetz On

You didn't post all of your source so it's hard to tell the exact problem. It seems to me that you need to have some logic around the variable wasAdShown, also you might want to make it a global variable.

I would do something like this:

wasAdShown = false

if wasAdShown == false then
   ads.show( "interstitial", { isAnimated = false, isBackButtonEnabled = true } )
   wasAdShown = true
else
   print "Ad Was Shown Already"
end
0
khawar ali On

do it like this

if (ads.isAdAvailable()) then local adShown = ads.show("interstitial", { isAnimated = false }) end

otherwise when ad get cached(loaded) it come to screen.