So I have been trying so much different things and I have reviewed many of the codes posted in the forum… but I can’t seem to get it to work.
I am trying to do a simple task, when the member loses the game, do a popup via the below code (only allows it 2 times per game)
local function endGame() if timesRewareded \< 2 and settingsTable.didWin == false then local alert = native.showAlert( "You have used up your 3 tries.", "Would you like to watch this short video ad to continue the game and get a free hint?", { "No Thanks!", "Yes!" }, onComplete ) else endGameNow() end end
Which button is clicked is checked by the onComplete function:
local function onComplete(event) if ( event.action == "clicked" ) then local i = event.index if ( i == 2 ) then --If clicked Yes! print("Clicked yes, lets watch a video!") appodeal.show("rewardedVideo") elseif ( i == 1 ) then --If clicked No thanks! --Cancel and just continue to end game print("Clicked no, lets end the game!") endGameNow() end end end
If they click no thanks, it just finishes ending the game and showing the score screen. If they press Yes, then it runs the video. This is where I am having the trouble. I can get the video to show fine… but the adListener event doesn’t seem to ever pick up the fact that the video is over or was watched.
Once it’s picked up that it has been watched I want to run the rewardThem() function, but it doesn’t seem to be running. Since the simulator doesn’t run ads, I can’t see if the rewardThem() function is running and just not working properly, or if its just not running at all.
local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) elseif ( event.phase == "playbackEnded") and (event.type == "rewardedVideo") then elseif (event.phase == "closed") then rewardThem() end end
I have placed the rewardThem() just about everywhere I can think of and no luck. Any ideas?