Adobe AIR Rewarded Ads - Enhance
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.
Example Usage
private function showAd():void { if(Enhance.isRewardedAdReady("level_complete")) { Enhance.showRewardedAd(onRewardGranted, onRewardDeclined, onRewardUnavailable, "level_complete"); } } private function onRewardGranted(type:String, value:int):void { if(type == Enhance.REWARD_ITEM) { trace("Reward granted (item)"); } else if(type == Enhance.REWARD_COINS) { trace("Reward granted (coins)"); trace("Reward value: " + value); } } private function onRewardDeclined():void { trace("User declined the reward"); } private function onRewardUnavailable():void { trace("No reward was available"); }
Methods
Enhance.isRewardedAdReady
Boolean Enhance.isRewardedAdReady(
optional String placement = "default"
)
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(
Function onRewardGrantedCallback,
Function onRewardDeclinedCallback,
Function onRewardUnavailableCallback,
optional String placement = "default"
)
Parameters:
Function 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).
Function onRewardDeclinedCallback
- Called when a reward is declined (e.g. user closed the ad before it finished displaying).
Function onRewardUnavailableCallback
- Called when a reward is unavailable for an unknown reason and cannot be granted.
optional String placement
- Specifies the internal placement of the ad (from the Enhance mediation editor).
Properties
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.