Applovin Rewarded Video not rewarding points

Hi

I am trying to implement Applovin Rewarded video but running into some issue. When I click on a button and video plays and completes, it does not reward the needed points in game. See code below:

-- AppLovin local applovin = require( "plugin.applovin" ) local function applovinVideo\_load() applovin.load() end local function applovinVideo\_Show() applovin.show() end local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) -- Load an AppLovin ad applovin.load() elseif ( event.phase == "loaded" ) then -- The ad was successfully loaded elseif ( event.phase == "failed" ) then -- The ad failed to load print( event.type ) print( event.isError ) print( event.response ) -- The user declined to view a rewarded/incentivized video ad elseif ( event.phase == "declinedToView" ) then print( "AppLovin event: user declined to view " .. tostring(event.type) .. " ad" ) -- The user viewed a rewarded/incentivized video ad elseif ( event.phase == "validationSucceeded" ) then print( "AppLovin event: " .. tostring(event.type) .. " ad viewed and reward approved by AppLovin server" ) -- Reward user here print ("save count before adding" .. savecount) savecount = savecount + 1 Lib.setSaveValue("savecount", savecount, true); print ("save count after adding" .. savecount) myData.label\_saveme.text = tostring( savecount ) -- local alert = native.showAlert("Successful","Ads loaded successfully!", {"OK"}) elseif ( event.phase == "clicked" ) then -- The ad was clicked/tapped print( event.type ) end end -- Initialize the AppLovin plugin applovin.init( adListener, { sdkKey="xxxxxxxxxxx", verboseLogging=false } )

Touch Event fr the button

-- Button touched buttonTouched = function(event) local t = event.target local id = t.id if event.phase == "began" and touchEnabled == true then display.getCurrentStage():setFocus( t ) t.isFocus = true t.xScale = 0.9 t.yScale = 0.9 elseif t.isFocus then if event.phase == "ended" then display.getCurrentStage():setFocus( nil ) t.isFocus = false t.xScale = 1 t.yScale = 1 local b = t.contentBounds if event.x \>= b.xMin and event.x \<= b.xMax and event.y \>= b.yMin and event.y \<= b.yMax then utils.playSound("select") if id == "applovin\_ads" then applovinVideo\_load() applovinVideo\_Show() else -- few more codes here end end end end return true end

Build version: 2016: 2949

Thanks

Both applovin.load() and applovin.show() take a boolean parameter which must be set to true for incentivized videos to load/show. If omitted the default value is false. Note that you must also enable “Rewarded Video” in the AppLovin developer portal to receive incentivized/rewarded videos in your app.

For further details see documentation here:

https://docs.coronalabs.com/plugin/applovin/index.html

Hi

I am confused a bit. The video shows when i click on my button but it does not reward user. By that I mean, it does not do this bit of the code:

savecount = savecount + 1 Lib.setSaveValue("savecount", savecount, true); print ("save count after adding" .. savecount) myData.label\_saveme.text = tostring( savecount )

When you call applovin.load() / applovin.show() (without passing true as an argument), a non-rewarded intersitial video is shown. To load and show a rewarded video you must pass true to the load and show functions as per the documentation below.

Documentation:

applovin.load(): https://docs.coronalabs.com/plugin/applovin/load.html

applovin.show(): https://docs.coronalabs.com/plugin/applovin/show.html

yes I saw all that and took the code from there but how do I set it to true? Any sample working code to help with to make life much easier for me :( 

OK I tried this and it appears to work but issue is it appears to repeat the reward twice so instead of just adding +1, it does +1 twice:

local function rewardedVideo\_load() applovin.load( isIncentivized ) end local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) -- Load an AppLovin ad elseif ( event.phase == "loaded" ) then -- The ad was successfully loaded print( event.type ) -- Show the ad applovin.show(isIncentivized) elseif ( event.phase == "failed" ) then -- The ad failed to load print( event.type ) print( event.isError ) print( event.response ) elseif ( event.phase == "displayed" or event.phase == "playbackBegan" ) then -- The ad was displayed/played print( event.type ) elseif ( event.phase == "hidden" or event.phase == "playbackEnded" ) then -- The ad was closed/hidden print( event.type ) savecount = savecount + 1 Lib.setSaveValue("savecount", savecount, true); myData.label\_saveme.text = tostring( savecount ) local alert = native.showAlert("New score",savecount, {"OK"}) elseif ( event.phase == "clicked" ) then -- The ad was clicked/tapped print( event.type ) end end -- Initialize the AppLovin plugin applovin.init( adListener, { sdkKey="xxxxxxxxxx", verboseLogging=false } )

Where do you define isIncentivized?

Hi Rob, I am just following the example below so not sure what you mean by define isIncentivized? Thanks

https://docs.coronalabs.com/plugin/applovin/show.html

When you see:  applovin.show( [isIncentivized] ) in the documentation, you need to read that that means:

isIncentivized (optional)

Boolean. Set this to true if you want to show an incentivized/rewarded video. Default is false. Note that you must enable “Rewarded Video” in the AppLovin developer portal to receive incentivized/rewarded videos in your app.

 

This says that applovin.show() takes a single parameter that is a boolean, it’s either true or false. The brackets tell you it’s an optional parameter.

So you can:

applovin.show( true ) -- gets incentive ads applovin.show( false ) -- gets non-incentive ads

You can optionally create a variable, named whatever you want, but we recommend “isIncentivized” as a good generic variable name. That means:

local isIncentivized = true applovin.show( isIncentivized )

is the same as:

applovin.show( true )

If you just do:

applovin.show( isIncentivized )

with out first creating a variable named isIncentivized it will default to nil, which in this case, its the same as nil. The simplest thing to do is just do:

applovin.load( true )

and

applovin.show( true )

Rob

Thanks for your help so far Rob but still couldn’t get this to work so I have given up on it.

Don’t give up. Can you post your code where you are attempting to load ads and where you are attempting to show ads?

It’s happening twice because of this:

elseif ( event.phase == “hidden” or event.phase == “playbackEnded” ) then – The ad was closed/hidden

IIRC, hidden and playbackEnded are both dispatched when the video ends.

Only increase the coins on playbackEnded.

@InfuseDreams that is interesting to know. Will try that now and see what happens

@Rob thanks and certainly won’t give up :). let me try InfuseDreams suggestion and see what happens.

Thanks @InfuseDreams & @Rob

removing event.phase == “hidden” worked.

Both applovin.load() and applovin.show() take a boolean parameter which must be set to true for incentivized videos to load/show. If omitted the default value is false. Note that you must also enable “Rewarded Video” in the AppLovin developer portal to receive incentivized/rewarded videos in your app.

For further details see documentation here:

https://docs.coronalabs.com/plugin/applovin/index.html

Hi

I am confused a bit. The video shows when i click on my button but it does not reward user. By that I mean, it does not do this bit of the code:

savecount = savecount + 1 Lib.setSaveValue("savecount", savecount, true); print ("save count after adding" .. savecount) myData.label\_saveme.text = tostring( savecount )

When you call applovin.load() / applovin.show() (without passing true as an argument), a non-rewarded intersitial video is shown. To load and show a rewarded video you must pass true to the load and show functions as per the documentation below.

Documentation:

applovin.load(): https://docs.coronalabs.com/plugin/applovin/load.html

applovin.show(): https://docs.coronalabs.com/plugin/applovin/show.html

yes I saw all that and took the code from there but how do I set it to true? Any sample working code to help with to make life much easier for me :( 

OK I tried this and it appears to work but issue is it appears to repeat the reward twice so instead of just adding +1, it does +1 twice:

local function rewardedVideo\_load() applovin.load( isIncentivized ) end local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) -- Load an AppLovin ad elseif ( event.phase == "loaded" ) then -- The ad was successfully loaded print( event.type ) -- Show the ad applovin.show(isIncentivized) elseif ( event.phase == "failed" ) then -- The ad failed to load print( event.type ) print( event.isError ) print( event.response ) elseif ( event.phase == "displayed" or event.phase == "playbackBegan" ) then -- The ad was displayed/played print( event.type ) elseif ( event.phase == "hidden" or event.phase == "playbackEnded" ) then -- The ad was closed/hidden print( event.type ) savecount = savecount + 1 Lib.setSaveValue("savecount", savecount, true); myData.label\_saveme.text = tostring( savecount ) local alert = native.showAlert("New score",savecount, {"OK"}) elseif ( event.phase == "clicked" ) then -- The ad was clicked/tapped print( event.type ) end end -- Initialize the AppLovin plugin applovin.init( adListener, { sdkKey="xxxxxxxxxx", verboseLogging=false } )

Where do you define isIncentivized?