How to get rewarded videos to work correctly?

I am using the appodeal plugin, I have successfully inputted all the info I need with appodeal and changed my build.settings file etc.

within my app I have required the plugin

local appodeal = require( "plugin.appodeal" )

I have implemented the following at the beginning of my scene:create(event) function.

appodeal.init( adListener, {appKey = "MY\_APP\_KEY", testMode = true} )

(my app key is actually there in my code, just wanted to put in a filler to be on the safe side)

and I have the function adListener referenced in my code

local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) end end

I then have a button that when pressed, initiates the rewarded video through this function.

local function rewardReady(event) if event.phase == "ended" then appodeal.show("rewardedVideo") end end

When I build this to my device and I push the button, the video plays just as expected.

I have a few things im still trying to figure out…

  1. How exactly do I grant the reward for watching the video

I figure it would be a conditional “if” statement in the adListener function, but I tried 

local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) elseif (event.phase == "playbackEnded") then gold = gold + 10 end end

But this did not work.

  1. I plan to have the button highlighted when there is an ad ready for the player to view if they choose and conversely the button will be dim and darkened when there is no video available to grant a reward.

I have all the images set up and I know how to change the frames of the button so it appears to light up etc. The problem is that I dont know how I should track if there is a video ready

I would assume that having the following runtime listener should help

rewardButton.enterFrame = adListener Runtime:addEventListener("enterFrame", rewardButton)

but again, I don’t know what I would be listening for to know that an ad is ready…

possibly event.phase.loaded???

please assist with any input

thank you

playbackEnded is indeed the event you are after. For rewarded videos, event.data will also contain properties on the amount and name of the reward.

https://docs.coronalabs.com/daily/plugin/appodeal/event/adsRequest/index.html

Make sure that you aren’t declaring your adListener below the appodeal.init() call, as you will then be assigning the listener to a nil value. The other option is to forward reference your adListener function.

Thank you

I made sure to declare my adListener BEFORE the appodeal.init()

Do I have to set up any info within the appodeal dashboard as to what to reward the player? or is that all done within corona?

You do indeed need to setup some details in the appodeal dashboard via the apps page: https://www.appodeal.com/apps/

See the below screenshot.

hsKIYtS.png

so, if I’m rewarding the player with in game currency, how exactly would that work?

If I use Gems as currency in my game and wanted to reward 5 Gems every time the player watches a rewarded video would I enter the following into appodeal…

Reward Amount: 5

Currency Name: Gems

I’m sure the currency name has to match exactly to the variable I use in corona correct?

and I would assume that is they key value pair that gets returned with the “event.data” you mentioned earlier, correct?

So event.data will be returned in this case (a table)

With the following key/pairs

amount - The reward amount

name - the reward/currency name

playbackEnded is indeed the event you are after. For rewarded videos, event.data will also contain properties on the amount and name of the reward.

https://docs.coronalabs.com/daily/plugin/appodeal/event/adsRequest/index.html

Make sure that you aren’t declaring your adListener below the appodeal.init() call, as you will then be assigning the listener to a nil value. The other option is to forward reference your adListener function.

Thank you

I made sure to declare my adListener BEFORE the appodeal.init()

Do I have to set up any info within the appodeal dashboard as to what to reward the player? or is that all done within corona?

You do indeed need to setup some details in the appodeal dashboard via the apps page: https://www.appodeal.com/apps/

See the below screenshot.

hsKIYtS.png

so, if I’m rewarding the player with in game currency, how exactly would that work?

If I use Gems as currency in my game and wanted to reward 5 Gems every time the player watches a rewarded video would I enter the following into appodeal…

Reward Amount: 5

Currency Name: Gems

I’m sure the currency name has to match exactly to the variable I use in corona correct?

and I would assume that is they key value pair that gets returned with the “event.data” you mentioned earlier, correct?

So event.data will be returned in this case (a table)

With the following key/pairs

amount - The reward amount

name - the reward/currency name