Integrate with Enhance - Xamarin
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 void OnRewardGranted(Enhance.RewardType rewardType, int rewardValue) { if (rewardType == Enhance.RewardType.Item) { writeLog ("Reward granted (item)"); } else if (rewardType == Enhance.RewardType.Coins) { writeLog ("Reward granted (coins)"); writeLog ("Reward value: " + rewardValue); } } private void OnRewardDeclined() { writeLog ("Reward declined"); } private void OnRewardUnavailable() { writeLog ("Reward unavailable"); } if (Enhance.IsRewardedAdReady()) { // The ad is ready, show it Enhance.ShowRewardedAd (OnRewardGranted, OnRewardDeclined, OnRewardUnavailable); }
Methods
Enhance.IsRewardedAdReady
bool 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(
optional string placement = "default",
Action<RewardType, int> onRewardGrantedCallback,
Action onRewardDeclinedCallback,
Action onRewardUnavailableCallback
)
Parameters:
optional string placement
- Specifies the internal placement of the ad (from the Enhance mediation editor).
Action<RewardType, int> 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
, and its value
as an integer (if applicable, depending on ad network's configuration).
Action onRewardDeclinedCallback
- Called when a reward is declined (e.g. user closed the ad before it finished displaying).
Action onRewardUnavailableCallback
- Called when a reward is unavailable for an unknown reason and cannot be granted.
Properties
string Enhance.DEFAULT_PLACEMENT
The default internal placement of all ad types. Always equal to "default"
.
Enhance.RewardType.Item
Indicates that the granted reward is a game-defined item.
Enhance.RewardType.Coins
Indicates that the granted reward is a specific number of coins.