Skip to main content

Rewarded Ad Units

Create Rewarded Ad Unit#

info

If you miss to Initialize the SDK, this method will fail to return a response.

All the steps to configure and show the rewarded ad are same as the interstitial except rewarded ads have an additional callback method onRewardsUnlocked for rewarding the user when they complete watching the ad content.

To create a new rewarded ad, create an MesonInterstitial object.

var rewardedAd: MesonInterstitial = MesonInterstitial.init(adUnitId: "AD_UNIT_ID", delegate: self)

Set the Delegate#

Track the ad lifecycle for rewarded ads. All the available events for rewarded ads are listed below.

extension <Class> : MesonInterstitialDelegate {
func mesonInterstitialDidLoad(_ interstitialAd: MesonInterstitial) {
}
func mesonInterstitialDidFailToLoad(_ interstitialAd: MesonInterstitial, error: Error) {
}
func mesonInterstitialImpression(_ interstitialAd: MesonInterstitial, impressionData: [String: Any]) {
}
func mesonInterstitialDidFailToDisplay(_ interstitialAd: MesonInterstitial, error: Error) {
}
func mesonInterstitialUserWillLeaveApplication(_ interstitialAd: MesonInterstitial) {
}
func mesonInterstitialWillDisplay(_ interstitialAd: MesonInterstitial) {
}
func mesonInterstitialDidDisplay(_ interstitialAd: MesonInterstitial) {
}
func mesonInterstitialWillDismiss(_ interstitialAd: MesonInterstitial) {
}
func mesonInterstitialDidDismiss(_ interstitialAd: MesonInterstitial) {
}
func mesonInterstitialDidClick(_ interstitial: MesonInterstitial, params: [String : Any]?) {
}
func mesonDidRewardUser(_ rewardedAd: MesonInterstitial, rewards: [String : Any]) {
}
}

Load Ad#

The publisher can request for a rewarded ad by invoking this method. This will request an ad from all demand sources, select a winner, and make it available on the SDK.

rewardedAd.load()

Show Ad#

The ad is available when load is called. It is shown to the user when show method is called. It is recommended to call this method in the mesonInterstitialDidFinishLoading callback method or check isReady and then call show method.

rewardedAd.show(from: <UIViewController>)