Implementing vungle in corona sdk - lua

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

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

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.

Related

Add reward video to Xamarin android app IsLoaded always return false

I'm trying to add a reward AdMob video to my app my code in onCreate is
Android.Gms.Ads.MobileAds.Initialize(ApplicationContext, "APP_CODE" );
mRewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this);
mRewardedVideoAd.RewardedVideoAdListener = this;
mRewardedVideoAd.LoadAd(#"ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().Build());
when i try to show the video by the following code
if (mRewardedVideoAd.IsLoaded)
mRewardedVideoAd.Show();
the mRewardedVideoAd.IsLoaded always return false
Is There any solution for this?

ios iAd loading before displaying

I'm working on a iOS game in swift.
I'm trying to add an interstitial ad.
What I would like to do is when the game is over, displaying an Ad.
After closing it, the user can launch another game.
When the game is over I call this method:
func showFullScreenAd() {
if requestingAd == false {
interstitial = ADInterstitialAd()
interstitial!.delegate = self
requestingAd = true
}
}
func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) {
if interstitial?.loaded==true{
....}
}
The ad will be displayed when interstitialAdDidLoad is called.
So, between showFullScreenAd() and interstitialAdDidLoad some times we may have several seconds (the time for the ad to load) so the user can click on 'new game' and starts the game.
So, the game will begin and then the ad will be displayed (I'm handling the pause mode also) but it's weird to start the game and to have the ad showing up.
I'm thinking about the following case:
doing
interstitial = ADInterstitialAd()
when loading the game
and when the game is over just show the ad (if available), and doing it again after that.
What do you think about this ?
Thanks.
C.C.
You have to add the ad onto the view as a subview right? So load it and add it to the view when you are ready to. I'm assuming that you're doing it before interstitialAdDidLoad at the moment?

Vungle ads sometimes not caching - Corona

I've integrated Vungle video ads in my Corona Game it was working perfect but few days ago it stopped caching video ads completely, but after few days it stared it self without changing any thing in code. Now it again stopped caching video ads. I suspect this issue is either from Corona or Vungle side but am not sure.
local vungleInterstitial = "540e9681c7ec2b6d4400000e"
local videoCompletedCallback=nil
videoAddListener=function( event )
if (event.isError ) then
--Cached video ad not available for display
print("problem to show ad")
elseif event.type == "cachedAdAvailable" then
print("cachedAdAvailable")
elseif tostring(event.type) == "adView" then
print("called when add is viewed")
elseif event.type == "adStart" then
print("Corona ads started")
audio.pause()
elseif event.type == "adEnd" then
print("Corona ads ended")
videoCompletedCallback()
audio.resume()
end
end
showVideoAd = function(callbackFunc)
print("showVideoAd function called")
videoCompletedCallback=callbackFunc;
if ( vads.isAdAvailable() ) then
print(" if ( vads.isAdAvailable() ) then, is true")
print("vads.show")
vads.show( "interstitial", { isBackButtonEnabled = false } )
else
local alert = native.showAlert( "Video Ad", "The Video Ad is not available at the moment. Please Try after some time.", { "OK" } )
end
end
vads.init("vungle",vungleInterstitial,videoAddListener)
This might be related to geo or daily view limits.. can you try with vungleTest as your AppID? Also, if you have further questions, feel free to email me at tech-support#vungle.com
Cheers,
Jordyn / Vungle

corona function to show ad when loaded does not work

I am trying to load an interstitial ad before actually showing it so that I can avoid lag. However everything I have tried has failed. With this code no ad ever appears:
local ads = require( "ads" )
ads.init( "admob", "ca-app-pub-2823622942892345/4361536298", adListener )
ads.load( "interstitial", { appId="ca-app-pub-2823622942892345/4361536298",
testMode=false } )
local function adListener( event )
if ( event.isError ) then
--Failed to receive an ad
else
ads.show( "interstitial", { x=0, y=0, appId="ca-app-pub-2823622942892345/4361536298" } )
end
end
With this code the ad loads but with lag...
local ads = require( "ads" )
ads.init( "admob", "ca-app-pub-2823622942892345/4361536298", adListener )
ads.load( "interstitial", { appId="ca-app-pub-2823622942892345/4361536298", testMode=false } )
ads.show( "interstitial", { x=0, y=0, appId="ca-app-pub-2823622942892345/4361536298" } )
Does anyone now why it does not work? If so how can I resolve it?
In your first example, your adListener function won't work. Since it's a local function and declared after you use it the first time, it will be nil on that first use. That function needs to be higher up in your code before it's used the first time.
In your second example, the ads.load() is an asynchronous call, that means we know it can take a while to work, so control returns to your app immediately and then you call ads.show() before the as has loaded and therefore nothing shows.
There is a tutorial that may help you with this:
http://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/

Issues while adding Revmob Full Screen Ads in Corona

I have added full screen Ads in my application but when i click on the cross button on the full screen Ads to close the Ads page and simultaneously click on the Ads Page to open the test window it sometimes gives error message attempt to call method 'didRemoveListener' a nil value, i have added code what i am writing in my application below, Please help to sort out this problem, thanks...
local RevMob = require("revmob")
display.setStatusBar(display.HiddenStatusBar)
local fullscreen
local revmobListener
local storyboard = require "storyboard"
local REVMOB_IDS = {
["Android"] = "",
["iPhone OS"] = ""
}
RevMob.startSession(REVMOB_IDS)
RevMob.setTestingMode(RevMob.TEST_WITH_ADS)
local function ShowAds()
fullscreen.RevMob.createFullscreen()
RevMob.showFullscreen(revmobListener, REVMOB_IDS)
end
revmobListener=function(event)
if(event.type=="adClicked" then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
elseif event.type=="adClosed" then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
end
ShowAds()
A way to solve it. Just accept the first touch.
local clicked = false
revmobListener=function(event)
if(event.type=="adClicked" and not clicked then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
clicked = true
elseif event.type=="adClosed" and not clicked then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
clicked = true
end

Resources