Back to top

Rewarded Ad Units

Last Updated on: 12 Jul, 2022

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 the 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 a MesonInterstitial object.

Swift

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

Objective-C

MesonInterstitial *rewardedAd = [[MesonInterstitial alloc] initWithAdUnitId:@"AD_UNIT_ID" delegate:self];

Register for Postbacks

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

Swift

extension <Class> : MesonInterstitialDelegate {
  
  func mesonInterstitialDidLoad(_ interstitialAd: MesonInterstitial) {
  }
  
  func mesonInterstitialDidFailToLoad(_ interstitialAd: MesonInterstitial, error: Error) {
  }
  
  func mesonInterstitialImpression(_ interstitialAd: MesonInterstitial, adData: MesonAdData?) {
  }
  
  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 mesonRewardsUnlocked(_ interstitial: MesonInterstitial, rewards: [String : Any]) { }  

}

Objective-C

- (void)mesonInterstitialDidLoad:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialDidFailToLoad:(MesonInterstitial *)interstitialAd error:(NSError *)error {
}

- (void)mesonInterstitialDidFailToDisplay:(MesonInterstitial *)interstitialAd error:(NSError *)error{
}

- (void)mesonInterstitialImpression:(MesonInterstitial *)interstitialAd adData:(MesonAdData *)adData{
}

- (void)mesonInterstitialDidClick:(MesonInterstitial *)interstitial params:(NSDictionary<NSString *,id> *)params {
}

- (void)mesonInterstitialUserWillLeaveApplication:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialWillDisplay:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialDidDisplay:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialDidDismiss:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialWillDismiss:(MesonInterstitial *)interstitialAd {
}

- (void)mesonRewardsUnlocked:(MesonInterstitial *)rewardedAd rewards:(NSDictionary<NSString *,id> *)rewards {
}

Load Ad

The publisher can request 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.

Swift

rewardedAd.load()

Objective-C

[rewardedAd load];

Show Ad

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

Swift

rewardedAd.show(from: <UIViewController>)

Objective-C

[rewardedAd showFromViewController:<ViewController>];