Hi,
I made a new topic two days ago because something wasn’t correct with the ads on my app. I pretty much solved that issue and decided to open a new topic so people with the same problem can find it as well.
This is the problem:
I’ve got an app that will show ads on 2 screens , either when you die and you want to continue playing you can watch an ad or if you don’t have enough in game credits , you can watch an ad to get a free item.
I’ve got two different adListeners setup for that, this is how both adListeners are written:
-
This is the one for when you die (it is initialized in a later stage of the scene)
function functions.applovinAdListener( event ) if ( event.phase == “init” ) then – Successful initialization print( event.isError ) – Load an AppLovin ad applovin.load() local isAdLoaded = applovin.isLoaded() print(“Ad loaded:” … isAdLoaded ) elseif ( event.phase == “loaded” ) then – The ad was successfully loaded print( event.type ) elseif ( event.phase == “failed” ) then – The ad failed to load print( event.type ) print( event.isError ) print( event.response ) applovin.load() elseif ( event.phase == “displayed” or event.phase == “playbackBegan” ) then – The ad was displayed/played print( event.type ) applovin.load() elseif ( event.phase == “hidden” ) then – The ad was closed/hidden print( event.type ) elseif ( event.phase == “clicked” ) then – The ad was clicked/tapped print( event.type ) end end
This is the one that you use when you are low on credits:
function functions.applovinShopAdListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) -- Load an AppLovin ad applovin.load() local isAdLoaded = applovin.isLoaded() print( isAdLoaded ) elseif ( event.phase == "loaded" ) then -- The ad was successfully loaded print( event.type ) elseif ( event.phase == "failed" ) then -- The ad failed to load print( event.type ) print( event.isError ) print( event.response ) applovin.load() elseif ( event.phase == "displayed" or event.phase == "playbackBegan" ) then -- The ad was displayed/played print( event.type ) applovin.load() elseif ( event.phase == "hidden" ) then -- The ad was closed/hidden print( event.type ) print("Ad hidden") settings.adAvailable = settings.adAvailable + 1 loadsave.saveTable(settings, "circleGameSettings.json") functions.freeRandomBall() elseif ( event.phase == "clicked" ) then -- The ad was clicked/tapped print( event.type ) print("Clicked") functions.freeRandomBall() end end applovin.init(functions.applovinShopAdListener, { sdkKey="MyKey" })
By debugging on my device, I found that when I launch an ad for credits and after that play the game and die and try to watch an ad to get an extra life, the wrong eventlistener is fired. I’ve read the tutorial on appLovin multiple times and went through the docs but I just can’t find the answer for this…
Is there anyone who knows how to fix this? I know that some ad networks give multiple keys for multiple ads, but that is not the case for applovin. Applovin provides one key/application.
Kind regards
Bram

