Hello Everyone,
I would need to ask for your help and advice.
I successfully built Applovin rewarded video ads into my app using Public Release 2016.2906.
With the same code, however, Applovin videos do not load/show using Public Release 2017.3068 and daily build 2017.3145.
There is not any error, simply the ads do not start. It seems to me like there is some problem during initialization.
I had checked forum entries and documentations, and made the following modifications in the earlier code (that worked well with 2016.2906):
1) “plugin.google.play.services” was removed from build.settings
The plugin part looks like this now:
[lua]
plugins =
{
[“plugin.applovin”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
},
[/lua]
2) In Applovin function calls the TRUE parameter was changed to the string “rewardedVideo” in every place.
The listener function looks like this (button2 is used to start a rewarded video if it has been loaded):
[lua]
local function adListener( event )
-----------------INIT
--------------------------
if ( event.phase == “init” ) then – Successful initialization
print( event.isError )
outputText.text = "message: INITIALIZED "…event.isError
– Load an AppLovin ad
if applovin.isLoaded( “rewardedVideo” ) == false then
applovin.load(“rewardedVideo”)
end
-----------------LOADED
--------------------------
elseif ( event.phase == “loaded” ) then – The ad was successfully loaded
print( event.type )
outputText.text = "message: LOADED "…event.type
button2.alpha = 1
button2:setEnabled(true)
-----------------REWARD
--------------------------
elseif ( event.phase == “validationSucceeded” ) then – Indicates that the user viewed the ad and that their reward was approved by the AppLovin server.
print( event.type )
audio.play(coinsReceivedSound)
outputText.text = "REWARD!!! validationSucceeded "…event.type
global_SilverCoins = global_SilverCoins + event.data.amount
silverCoinBlock.refreshCoinValues()
goldCoinBlock.refreshCoinValues()
– Load an AppLovin ad
if applovin.isLoaded( “rewardedVideo” ) == false then
applovin.load(“rewardedVideo”)
end
-----------------EXCEED QUOTA
--------------------------
elseif ( event.phase == “validationExceededQuota” ) then – Indicates that the AppLovin server was contacted, but the user has already received the maximum amount of rewards allowed in a given day.
print( event.type )
outputText.text = "message: validationExceededQuota "…event.type
-----------------FAILED
--------------------------
elseif ( event.phase == “failed” ) then – The ad failed to load
print( event.type )
outputText.text = "FAILED “…” “…event.type…” “…event.isError…” "…event.response
– Load an AppLovin ad
if applovin.isLoaded( “rewardedVideo” ) == false then
applovin.load(“rewardedVideo”)
end
-----------------DISPLAYED
--------------------------
elseif ( event.phase == “displayed” ) then – Indicates that a graphical interstitial ad (non-video) was displayed.
print( event.type )
outputText.text = “message: DISPLAYED”…event.type
-----------------PLAYBACK BEGAN
--------------------------
elseif ( event.phase == “playbackBegan” ) then – Indicates that a video interstitial ad was displayed.
print( event.type )
outputText.text = "message: PLAYBACK BEGAN "…event.type
-----------------HIDDEN
--------------------------
elseif ( event.phase == “hidden”) then – Indicates that a graphical interstitial ad (non-video) was closed/hidden.
print( event.type )
outputText.text = "message: HIDDEN "…event.type
-----------------PLAYBACK ENDED
--------------------------
elseif ( event.phase == “playbackEnded” ) then – Indicates that a video interstitial ad was closed/hidden.
print( event.type )
outputText.text = "message: PLAYBACK ENDED "…event.type
– Load an AppLovin ad
if applovin.isLoaded( “rewardedVideo” ) == false then
applovin.load(“rewardedVideo”)
end
-----------------CLICKED
--------------------------
elseif ( event.phase == “clicked” ) then – Indicates that an ad was clicked/tapped.
print( event.type )
outputText.text = "message: CLICKED "…event.type
-----------------DECLINED TO VIEW
--------------------------
elseif ( event.phase == “declinedToView” ) then – Indicates that the user chose “no” when prompted to view the ad.
print( event.type )
outputText.text = "message: declinedToView "…event.type
– Load an AppLovin ad
if applovin.isLoaded( “rewardedVideo” ) == false then
applovin.load(“rewardedVideo”)
end
end
end
[/lua]
3) I tried to move the adListener and all the Applovin INIT calls to main.lua.
Originally (with 2016.2906) everything was placed in a separate LUA file of a dedicated Composer Scene handling rewarded videos, and INIT was called during its SCENE CREATE:
[lua]
– Initialize the AppLovin plugin
applovin.init( adListener, { sdkKey=mySDKKey } )
[/lua]
Unfortunately, neither of the above points did the trick.
Nevertheless, I was also wondering about the following at point 3):
-
Does it make any sense to change the adListener to be global instead of local? Does it make any change during Applovin INIT?
-
If the adListener defined in main.lua is local, will it work during my separate rewarded video’s Composer Scene phase?
-
Is it a must to call APPLOVIN INIT in main.lua?
-
What happens if we require applovin as:
[lua]
applovin = require( “plugin.applovin” )
[/lua]
instead of:
[lua]
local applovin = require( “plugin.applovin” )
[/lua]
-
Does it “overwrite” the Applovin INIT (and the adListener) of main.lua if I again require Applovin in my separate rewarded video Composer Scene?
-
How could I refer from main.lua to the video play button of the separate Composer Scene (button2) in the adListener?
I gratefully look forward to any tips, hints, help or advice.
Thank you in advance!
With best regards,
Zsolt