How to do Appodeal rewarded videos?

Note: I know this is a repost but I wanted to move the forum post to general. I will delete the orignal post I made in Corona API section.

So I contacted support for Appodeal and they gave me this:

https://www.appodeal.com/sdk/corona_beta (look at 5.1)

I already read that and still didnt tell me exactly how to do rewarded videos.

Lets say I want the reward to be:

composer.gotoScene( "menu")

How do I do this?

Here is all I have:

local appodeal = require( "plugin.appodeal" ) local function adListener( event )     if ( event.phase == "init" ) then  -- Successful initialization         print( event.isError ) appodeal.show( "rewardedVideo")     end end -- Initialize the Appodeal plugin appodeal.init( adListener, { appKey="NOT\_SHOWING" } )

 Much help is appreciated.

This is really the final step in our app.

Normally you would call the .load() method to load the ad. Video ads take time to download, so pre-loading them is important.  You also probably should not be showing an ad as soon as you initialize everything in your app, which you are trying to do by calling .show() after you get your init complete event.  I would instead call .load() instead of .show() to begin preloading the ad.

Then in the scene where you intend to show the ad, you can test the .isLoaded() method to make sure the ad is loaded and then call .show() at that point.

Rob

Ah thank you!

but how do i give the reward?
 

I got this but doesnt work:

local appodeal = require( "plugin.appodeal" ) local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) end if ( event.phase == "closed" ) then -- Successful initialization print( event.isError ) composer.gotoScene("game") end end -- Initialize the Appodeal plugin appodeal.init( adListener, { appKey="" } )

if ( appodeal.isLoaded( “rewardedVideo” ) ) then

    appodeal.show( “rewardedVideo”,{placement=“intPlacement”} )

end

@Joe - What does it mean to you to ‘get a reward’?

For example, do you mean, the player gets some coins, or a level unlocks, what?

Also, you really need to understand:

  • The concept of listeners and how to code yours to do what you want.
  • How ads work and what data they provide the listener to tell you what has just happened.
  • How to listen for events and do something as a result.
  • How to save information to persistent storage if that is part of your reward system.

There is no single solution to this, otherwise it would just come rolled into the SDK.  This is a pure custom coding thing so you’ll probably want to settle in for a lot of homework, experimentation, and learning, …OR…

You might want to pay someone to write it for you.  

PS - All of this information is pretty well documented, but you have to read every function description and dig into the links to events, etc. starting here: https://docs.coronalabs.com/plugin/appodeal/index.html

For example, have you seen/read this and do you know what it means? 

I already explained it above but a little more clarification:

I have revive button,

when the user clicks on the button a reward video shows up,

when the video ends, the player will be taken back to the game scene where they play again.

I have got all that to work except for the part when the video ends and the player is taken back to the game.

This is all I have:

local appodeal = require( "plugin.appodeal" ) local function adListener( event )     if ( event.phase == "init" ) then  -- Successful initialization         print( event.isError )     end if ( event.phase == "closed" ) then  -- Successful initialization         print( event.isError ) composer.gotoScene("game")     end end -- Initialize the Appodeal plugin appodeal.init( adListener, { appKey="" } ) if ( appodeal.isLoaded( "rewardedVideo" ) ) then     appodeal.show( "rewardedVideo",{placement="intPlacement"} ) end

Any ideas?

Okay maybe I should rephrase my question:

How can I make the scene change when a rewarded video ends?

Are you posting your actual code? Or are you copying parts and posting them so it looks like one block of code?

Where are you preloading the ad?

Where are you printing out the content of the event table that your adListener is receiving? You should be dumping this table so you can look at your device’s console log to see what’s going on.

Are you testing on a device?

Are you getting a rewarded video?

Rob

Ok well figured it out myself.

Sometimes when the video ends it doesn’t give the reward.

Thats why i display a message telling the user to "click here to revive) just before the ad shows up .

Most of it is actual code except for the if statement after init().

I saw other recent posts and found out how they did the reward video thing.

@rob if i am not mistaken the appodeal plugin documentation states that calling appodeal.load is not necessary and it caches ads by default on init , please correct me if i am wrong.
 
@Joe i think the best phase to reward your player is on “playbackEnded” and not on “closed” , 

i am checking : 

if event.phase == "playbackEnded" and event.type=="rewardedVideo" then  

I tried that but it didnt work…

Joe,

Add code to your listener to print out ALL of the details of the event, then run some tests till you understand what events happen when and what fields get set based on the actions you take.

Once you understand this, it will be straightforward.

Even better, do what I do when I investigate a new ad plugin.

Make a test bench with buttons and visual feedback right on the screen that allow you to load, show, etc.

Then you can easily test out how things work and see what happens.

I don’t know if you have any interest in this, but I expect to have a framework ready by early to mid next week to simplify using Appodeal and Applovin even more.

They are both pretty easy to use, but my framework will make it drop-dead-simple to get this stuff working and give you the added bonus of being able to test your ad logic in the simulator.

If this discussion is still active when I release it, I’ll cross post here.

Oh yes please do!

Here is that post I promised to cross link: 

https://forums.coronalabs.com/topic/73312-starters-core/

Normally you would call the .load() method to load the ad. Video ads take time to download, so pre-loading them is important.  You also probably should not be showing an ad as soon as you initialize everything in your app, which you are trying to do by calling .show() after you get your init complete event.  I would instead call .load() instead of .show() to begin preloading the ad.

Then in the scene where you intend to show the ad, you can test the .isLoaded() method to make sure the ad is loaded and then call .show() at that point.

Rob

Ah thank you!

but how do i give the reward?
 

I got this but doesnt work:

local appodeal = require( "plugin.appodeal" ) local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) end if ( event.phase == "closed" ) then -- Successful initialization print( event.isError ) composer.gotoScene("game") end end -- Initialize the Appodeal plugin appodeal.init( adListener, { appKey="" } )

if ( appodeal.isLoaded( “rewardedVideo” ) ) then

    appodeal.show( “rewardedVideo”,{placement=“intPlacement”} )

end

@Joe - What does it mean to you to ‘get a reward’?

For example, do you mean, the player gets some coins, or a level unlocks, what?

Also, you really need to understand:

  • The concept of listeners and how to code yours to do what you want.
  • How ads work and what data they provide the listener to tell you what has just happened.
  • How to listen for events and do something as a result.
  • How to save information to persistent storage if that is part of your reward system.

There is no single solution to this, otherwise it would just come rolled into the SDK.  This is a pure custom coding thing so you’ll probably want to settle in for a lot of homework, experimentation, and learning, …OR…

You might want to pay someone to write it for you.  

PS - All of this information is pretty well documented, but you have to read every function description and dig into the links to events, etc. starting here: https://docs.coronalabs.com/plugin/appodeal/index.html

For example, have you seen/read this and do you know what it means?