How to use the Vungle listener? Does it work?

Hello guys,

So far I am having a lot of fun with Vungle. I am even just running my app just to watch the video ads (I know that’s sick!) Since I am hoping to switch between Vungle, Revmob and Chartboot I am trying to use Vungle listener to detect that Vungle was not able to show a video so I can show either Chartboost or Revmob.

I was looking at the list of events returned but there is nothing about a fail  to show other than event.isError? is that the event I need?

Another and bigger issue is that for some reason my listener do not seems to be called? I setup some print to display of the event name and type but even so the ad shows up on the device  I cannot see any print out which basically means the listener is not called. I checked the naming but so far no luck.

Anybody “played” with the listener?

THANKS!!

Mo

Ok, made some progress. I can see now the event listerner triggering and the print out of the name and type.

But no luck. The bizarre thing is that I also try to print the event.isError status but it is not displayed in the xcode console for some reason?

Aslo,  i need to figure out how to show another ad network if Vungle fail to show an ad. I can see this (Xcode console)  when it is showing an ad

event.name = adRequest

event.type = adStart

event.name = adRequest

event.type = adview

event.name = adRequest

event.type = adEnd

BUT the ad is not show the only event I see are:

event.name = adRequest

event.type = adStart

I tried using:

[lua]

if event.type == “adStart” and event.isError then               

 showRevmob()

end

[/lua]

Mo

EDIT: it is working now! The code above seems to display Revmob if Vungle has nothing to show. I also see now the isError status. I was printing using print("error = "…isError) instead of print("error = " , isError) !!!

Hi Mo,

I think this is not the best way to handle it.

Did you take a look at their example at github ?

-- show an ad if one has been downloaded and is available for playback function showAd()     ads.show( "interstitial", { isBackButtonEnabled = true } ) end -- event table includes: --        event.name        =    'adsRequest' --        event.provider    =    'vungle' --        event.type            (string - e.g. 'adStart', 'adView', 'adEnd') --        event.isError        (boolean) --        event.response        (string) -- create a 'function' ad listener function functionAdListener( event )     -- video ad not yet downloaded and available     if event.type == "adStart" and event.isError then         statusText.text = "Downloading video ad ..."         statusText.x = display.contentWidth \* 0.5         -- wait 5 seconds before retrying to display ad         timer.performWithDelay(5000, showAd)     -- video ad displayed and then closed     elseif event.type == "adEnd" then         statusText.text = "Hope you enjoyed the video!"         statusText.x = display.contentWidth \* 0.5     else         print( "Received event:")         vardump( event )     end end  

They wait a bit if this is true and then try to call the ad again.

if event.type == "adStart" and event.isError then  

Guess this is because a video ad takes time to load.

If I was you, I would call showRevmob() if you get the event.isError the second time.

Anyway, I think they miss a call that would pre-cash the video ad, something like ad.cache().

Then we could call if(ads.isAdAvailable()) ads.show() at any time we think is best for the user experience.

The problem I see right now is that if I call the ads.show() at game start, the user switches to the game-play screen and starts playing, and suddenly the video ad shows is not the best experience.

With ads.cache() we could call it on game start and the call ads.show() e.g. when the user finish playing.

Regards,

Damir.

I’ve just started playing with this myself, and as I understand it they’re already pre-caching their ads automatically after calling init().

I use if(ads.isAdAvailable()) ads.show() which is working very well so far. (I don’t try to show a vungle ad immediately on startup though, I use RevMob for that)

I have my own gamestate variable that I check and if the user is in any game-play state I don’t show/ignore that particular ad.

So far vungle looks great.

Thank you guys! @ubj3d: How you would you check for a second error? a flag, counter?  I believe ingemar is right about caching. I do call the caching function but i should try:

[lua]

if (ads.isAdAvailable()) then

ads.show()

else

showRevmob()

end

[/lua]

As ingemar, I do not use Vungle at app launch or resume. I use Chartboost first and if it fails then I use Revmob. In that order because Revmob has basically 100% fill rate. So I want to give Chartboost a first bite at the apple because I can control the minimum CPI i will accept!

I am still having issues with the show ad logic but it seems to work relatively well. When i try to show Vungle and nothing is there, it tries Chartboost. If Chartboost fails then it shows Revmob. Later on I will add cross promotion for my first app since I will soon have a second app!

If anybody has tried to integrate multiple ad networks logic)  I will love to hear about it!

Thanks again,

Mo

Hi Mo,

yes I was thinking about using a counter variable to check for the second error.

Another way would be to use if(ads.isAdAvailable()) ads.show().

Guess if you then get an error in the listener it is a “real” error (e.g. no ad available).

About using multiple ad networks, we have implemented a sophisticated method which involves a server with a database and a special made app also made in Corona where we can switch ads on/off, give each ad network a percentage of “ad space”, change the frequency of interstitilas etc.

We have integrated almost all ad networks available in Corona which deserved our attention during testing.

Now we are waiting for Apple to recover from the attack…

Regards,

Damir.

When I call .isAdAvailable() I get en error stating it’s a nil value.

Could you assist me with my code please?

--- main.lua: local ads = require "ads" local provider = "vungle" local appId = "someID" storyboard.state.showVungle = function() ads.show( "interstitial", { isBackButtonEnabled = true } ) end storyboard.state.hasCachedVungle = function() ads.isAdAvailable() end local function functionAdListener( event ) end ads.init( provider, appId, functionAdListener ) --- storyboardScene.lua: --- when I call it I get an error saying that isAdAvailable = nil if storyboard.state.hasCachedVungle() then storyboard.state.showVungle() end

When I call to show vungle without checking ads.isAdAvailable() value - it works fine.

Olaf

You have to run it on a device (or iPhone Simulator).

To avoid the error in the Corona Simulator, just test if system.getInfo(“environment”) == “simulator” and skip the call.

I run it on the device and while it doesn’t print an error it behaves (the logic) like the isAdAvailable = nil :frowning:

so it’s not displaying any ad. Once I remove the isAdAvailable conditional - the ads are beeing displayed, so it should return true, when called. I don’t know what’s happening here.

That’s a bit weird. I had that problem too, but only in the Corona Simulator.

Once I ran it on a device (both Android and Apple) I had no issues…

SOLVED

OK, I guess there was some method-nesting issue (not sure why, though)

Now I require(“ads”) in all my modules and just call directly ads.isAdAvailable() and it works fine.

Anyway thanks!

can you use the vungle android key for your Nook app?

So far, the only issue I see with Vungle in “test mode” is that I cannot really test failures to deliver video (so I can switch to another ad network) I try turning off the campaign but for some reason the video test keep coming not matter what. Anyway to simulate or trigger a failure? Maybe making sure the test mode obey the setting of the campaign (on or off)

Thanks a lot for a great system!

Mo

EDIT:  I am SO sorry! I need new glasses:) I turned off Charboost instead of Vungle and was hoping for Vungle to stop delivering video ads. I had a Mo(ment) Sure enough when I disable Vungle, the video stopped showing! Not sure if disabling Vungle is enough to fully test video ads failure to show but for now I am satisfied.  Maybe when I am almost ready to release, I can switch to “live” to make absolutely sure that my app can react to a real life situation.

Again, SORRY:(

Hi Mo,

How can i use chartboost, revmob and vungle together in my app? How do I deal with the READ_PHONE_STATE which should be enabled for revmob and vungle but disabled for chartboost?

Can you help me with the implementation code.

I am afraid not. I am only working on the IOS version. Maybe someone who is working with Android can answer your question. For me :

Since Revmob has a fill rate of basically 100%, I will call it last. So if Vungle then Chartboost fail to show up then I will call Revmob. You basically start by showing Vungle (for instance) then use the listeners to watch for a failure to deliver and launch Chartboost from there. Finally if Chartboost fail also then simply show Revmob.

EventuallyI will show a personal ad (showing my upcoming app) last (if Revmob fail also) but for now if Revmob fail then I call it a day…

Cheers.

Mo

Mo,

Do you block access to your games if Internet isn’t available on the device?

@sagarpawaskar

I let my users run my apps even without internet access. I don’t give a notification either. I just gracefully let the user run the app. The reason being that there are many places and devices in the world where constant Internet access just isn’t possible (for Wifi only devices etc).

IMO I don’t think that forcing an Internet connection is a good idea. At least for apps that absolutely don’t *need* it.

Same here :slight_smile: Mo

But users may take advantage of it and run games disabling internet. Don’t we lose our revenue?

Anyway, I guess you made a fair point. I’ll drop my internet check and follow you guys. Thank you!

Sagar

OFF-TOPIC:

@sagarpawaskar

Yes…That is true. But personally I’ve wasted countless of hours trying to prevent pirates to run my apps, and it’s been a waste of my time. If they want to crack your app, they will eventually succeed no matter how much effort you put in to preventing it.

I’m just a small studio with few developer resources and my time is better used to create new apps than writing anti-piracy code.

If my apps are worth pirating, I guess that it’s a good sign that something must be right, and I now consider any pirate copies as “free advertising”. Not everybody is a pirate and I believe that some of those copies will result in legal downloads as well.