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