Home


Rewarded Ads

Rewarded Ads are usually full-screen video ads which users can view to receive a reward inside the app, like an additional in-game currency or a health bonus for example.

var onRewardGranted = function(rewardType:String, rewardValue:Int) 
{ 
    if(rewardType == Enhance.REWARD_ITEM)
        _logOutput.writeLog("Reward granted (item)");

    else if(rewardType == Enhance.REWARD_COINS)
        _logOutput.writeLog("Reward granted (coins), value: " + rewardValue);
};

var onRewardDeclined = function() {
    _logOutput.writeLog("Reward declined");
};

var onRewardUnavailable = function() {
    _logOutput.writeLog("Reward unavailable");
};

if(Enhance.isRewardedAdReady()) {
    Enhance.showRewardedAd(onRewardGranted, onRewardDeclined, onRewardUnavailable);
}

Methods

Enhance.isRewardedAdReady

Bool Enhance.isRewardedAdReady(
    optional String placement = "default"
)

Check if an ad from any of the included SDK providers is ready to be shown.

Parameters:

optional String  placement - Specifies the internal placement of the ad (from the Enhance mediation editor).

Return Value:

Returns true if any ad is ready, false otherwise. When app is not Enhanced, always returns true.

Enhance.showRewardedAd

Void Enhance.showRewardedAd(
    optional String placement = "default",
    String->Int->Void onRewardGrantedCallback,
    Void->Void onRewardDeclinedCallback,
    Void->Void onRewardUnavailableCallback
)

Display an ad if any is currently available. The ad provider is selected based on your app's mediation settings.

Parameters:

optional String  placement - Specifies the internal placement of the ad (from the Enhance mediation editor).

String->Int->Void  onRewardGrantedCallback - Called when an ad is finished and a reward is granted to the user. As parameters, this function will receive the reward's type as a string (which usually is either "item" or "coins"), and its value as an integer (if applicable, depending on ad network's configuration).

Void->Void  onRewardDeclinedCallback - Called when a reward is declined (e.g. user closed the ad before it finished displaying).

Void->Void  onRewardUnavailableCallback - Called when a reward is unavailable for an unknown reason and cannot be granted.

String Enhance.PLACEMENT_DEFAULT

The default internal placement of all ad types. Always equal to "default".


String Enhance.REWARD_ITEM

Indicates that the granted reward is a game-defined item.


String Enhance.REWARD_COINS

Indicates that the granted reward is a specific number of coins.