Question about Appodeal plugin basics

I am having some issues when using the Appodeal plugin in my game.

Could you please tell me the correct way to implement the appodeal plugin when using composer. I want to know about these:

1)When to call appodeal.init and appodeal.show etc and in which file, main.lua or scene.lua?
 

2)What code should I put in the adListener function which is called by appodeal.init ?
 

3)Should I hide banner ads when changing scene and then show them again in the next scene or should not hide banner ads at all ?
 

4)Does appodeal’s autocaching in background effect my app’s performance (because I have seen performance degradation when using the plugin) ?

In main.lua, write your listener function and call .init().

-- main.lua local appodeal = require( "plugin.appodeal" ) local appodealIOSkey = "really long string from the appodeal dashboard for iOS" local appodealANDROIDkey = "really long string from the appodeal dashboard for Android" local appodealKey if "iPhone OS" == platform then appodealKey = appodealIOSkey elseif "Android" == platform then appodealKey = appodealANDROIDkey end local function appodealListener( event ) print( json.prettify( event )) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) elseif event.phase == "playbackEnded" and event.data then local amount = event.data.amount -- -- Do stuff here to handle rewarded video -- end end appodeal.init(appodealListener, { appKey = appodealKey, locationTracking = false, supportedAdTypes = {"rewardedVideo", "banner", "interstitial" }, testMode = true })

Then in scene.lua you would call appodeal.show() at the appropriate time. If you’re showing banner ads, you perhaps want to call appodeal.show() in scene:show()'s ‘did’ phase (after the scene is fully on the screen). Banners will typically need hidden, so call appodeal.hide() in scene:hide()'s ‘will’ phase. 

As a general rule, for video, interstitial and rewardedVideo you do not need to hide them. The user will be asked to dismiss the ad and you want them to take that action. If your game is one where it make sense for  a banner add to stay on the screen between multiple scenes, then you don’t need to hide them. If you’re going to a scene where it doesn’t make sense to have a banner ad, then hide it. You probably should hide it before you show any of the full screen ad types.

What code to put in the listener? That question is way too broad to give you any specifics. We have no idea what you’re trying to do. If you’re doing rewardedVideo, perhaps you would add the reward to a variable. Say your giving 50 coins to watch a video, you could detect “playbackEnded” and then do a coins = coins + 50. Now if your going to depend on Appodeal to allow you to change values and such, you can get the amount of the reward and add that instead of a fixed amount.

Of course the listener is in main.lua so you will  have to use various techniques to get to your variable to change it. I personally use a faux global data table (see: https://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/) and have things like coins as part of that table. But you could use Composer’s getVariable and setVariable API calls to also set variables. 

Rob

In main.lua, write your listener function and call .init().

-- main.lua local appodeal = require( "plugin.appodeal" ) local appodealIOSkey = "really long string from the appodeal dashboard for iOS" local appodealANDROIDkey = "really long string from the appodeal dashboard for Android" local appodealKey if "iPhone OS" == platform then appodealKey = appodealIOSkey elseif "Android" == platform then appodealKey = appodealANDROIDkey end local function appodealListener( event ) print( json.prettify( event )) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) elseif event.phase == "playbackEnded" and event.data then local amount = event.data.amount -- -- Do stuff here to handle rewarded video -- end end appodeal.init(appodealListener, { appKey = appodealKey, locationTracking = false, supportedAdTypes = {"rewardedVideo", "banner", "interstitial" }, testMode = true })

Then in scene.lua you would call appodeal.show() at the appropriate time. If you’re showing banner ads, you perhaps want to call appodeal.show() in scene:show()'s ‘did’ phase (after the scene is fully on the screen). Banners will typically need hidden, so call appodeal.hide() in scene:hide()'s ‘will’ phase. 

As a general rule, for video, interstitial and rewardedVideo you do not need to hide them. The user will be asked to dismiss the ad and you want them to take that action. If your game is one where it make sense for  a banner add to stay on the screen between multiple scenes, then you don’t need to hide them. If you’re going to a scene where it doesn’t make sense to have a banner ad, then hide it. You probably should hide it before you show any of the full screen ad types.

What code to put in the listener? That question is way too broad to give you any specifics. We have no idea what you’re trying to do. If you’re doing rewardedVideo, perhaps you would add the reward to a variable. Say your giving 50 coins to watch a video, you could detect “playbackEnded” and then do a coins = coins + 50. Now if your going to depend on Appodeal to allow you to change values and such, you can get the amount of the reward and add that instead of a fixed amount.

Of course the listener is in main.lua so you will  have to use various techniques to get to your variable to change it. I personally use a faux global data table (see: https://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/) and have things like coins as part of that table. But you could use Composer’s getVariable and setVariable API calls to also set variables. 

Rob