Easy Ads

The Starters Core kit comes with the Easy Ads modules.

These modules:

Using Easy Ads

This video demonstrates how to use Easy Ads to show Appodeal ads.

EFM

Project Settings

Please see the Corona docs for setting up the build.settings file.

Selecting Helper

AppLovin

_G.adsHelper = require( "easy.ads.applovinAds" )

Appodeal

_G.adsHelper = require( "easy.ads.appodealAds" )

Preparation & Initialization

AppLovin

adsHelper.prepare( enabled, adParams )

Example

adParams = {
  androidID               = "BCD4524908adfADFAVDS234523DSNB",
  iosID                   = "LMND124908adfADFAVDS234523DYND",
  interstitialAfterInit   = {},
}
adsHelper.prepare( true, adParams )

Appodeal

adsHelper.prepare( enabled, adParams )

Example

adParams = {      
  testMode          = true,
  verbose           = false,
  initDelay         = 30,
  androidID         = "BCD4524908adfADFAVDS234523DSNB",
  iosID             = "LMND124908adfADFAVDS234523DYND",
  supportedAdTypes  = { "banner", "rewardedVideo" },
  isCOPPACompliant  = false,
  hasGDPRConsent    = true,
  enableFakeAds     = true, 
  bannerAfterInit   = { position = "bottom" },
}
adsHelper.prepare( true, adParams )

Showing Ads

Banners

showBanner( [ position [, placement ] ] )

_G.adsHelper.showBanner( "bottom" )

Interstitials

showInterstitial( [ position [, placement ] ] )

local function onComplete()
    print("Showed interstital!")
end

_G.adsHelper.showInterstitial( onComplete )

Rewarded Ads

showRewarded( [ onSuccess [, onFailure [, placement ] ] ] )

local function onSuccess()
    print("Give reward!")
end

local function onFailure()
    print("No Twinky For You!")
end

_G.adsHelper.showRewarded( onSuccess, onFailure, "earn_coins_button" )

Hiding Banners

_G.adsHelper.hideBanner()

Advanced Features

You will probably never need these features, but just in case here are the docs.

Temporary Listeners

You can set up unique listeners that are transient in nature. Once the specific event you are waiting for occurs, these listeners can be removed. Alternately, you can clear them manually.

listen( name, aListener )

Call this function to add a temporary ad listener. You can then clear it as needed.

Example

 local function clear()
    _G.adsHelper.ignore( "interstitial" )
 end

 local function interstitialListener( event )         
    local isError  = event.isError
    local phase    = event.phase
    --
    if( isError and phase == "rewardedVideo" ) then
       clear()
       return
    end

    --
    -- Catch all 'ended' equivalent phases and assume that 
    -- the first one means we have shown the interstitial.
    if( phase == "hidden" or phase == "playbackEnded" ) then
       clear()
       print("Yay! Showed interstial.")
    end
 end
 _G.adsHelper.listen( "interstitial", interstitialListener )

ignore( name )

Call this function to remove a previously added temporary listner.

 _G.adsHelper.ignore( "interstitial" )

ignoreAll()

Call this function to remove all temporary listner.

 _G.adsHelper.ignoreAll( )

AppLovin Specific Helpers

The AppLovin helper also exposes these functions:

Appodeal Specific Helpers

The Appodeal helper also exposes these functions:

Disabling Helper

If you find that you want to disable all features of the active helper for the remainder of the app run, you can do so with the disableModule() function. (It can only be called once. Subsequen calls do nothing.)

disableModule( [doCleaning] )

_G.adsHelper.disableModule( true )

Standard Plugin Features?

You can always use the other features of the AppLovin and Appodeal plugins just like you normally would.

Please see the Corona docs:


RoamingGamer Copyright © Roaming Gamer, LLC. 2008-2018; All Rights Reserved