Rewarded ads let you offer users in-app items—such as continued gameplay, virtual currency, or other rewards—in exchange for their engagement with ads. Rewarded ads boost engagement because users receive a tangible benefit for their time.
The following sections show you how to load and then show a rewarded ad.
To load a rewarded ad, get an instance of a MARewardedAd object that corresponds to your rewarded ad unit and then call its loadAd method.
Implement MARewardedAdDelegate so that you are notified when your ad is ready.
This also notifies you of other ad-related events.
#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>
@interface ExampleViewController()<MARewardedAdDelegate>
@property (nonatomic, strong) MARewardedAd *rewardedAd;
@property (nonatomic, assign) NSInteger retryAttempt;
@end
@implementation ExampleViewController
- (void)createRewardedAd
{
self.rewardedAd = [MARewardedAd sharedWithAdUnitIdentifier: @"«ad-unit-ID»"];
self.rewardedAd.delegate = self;
// Load the first ad
[self.rewardedAd loadAd];
}
#pragma mark - MAAdDelegate Protocol
- (void)didLoadAd:(MAAd *)ad
{
// Rewarded ad is ready to show. '[self.rewardedAd isReady]' now returns 'YES'
// Reset retry attempt
self.retryAttempt = 0;
}
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
self.retryAttempt++;
NSInteger delaySec = pow(2, MIN(6, self.retryAttempt));
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self.rewardedAd loadAd];
});
}
- (void)didDisplayAd:(MAAd *)ad {}
- (void)didClickAd:(MAAd *)ad {}
- (void)didHideAd:(MAAd *)ad
{
// Rewarded ad is hidden. Pre-load the next ad
[self.rewardedAd loadAd];
}
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
[self.rewardedAd loadAd];
}
#pragma mark - MARewardedAdDelegate Protocol
- (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
{
// Rewarded ad was displayed and user should receive the reward
}
@end
class ExampleViewController : UIViewController, MARewardedAdDelegate
{
var rewardedAd: MARewardedAd!
var retryAttempt = 0.0
func createRewardedAd()
{
rewardedAd = MARewardedAd.shared(withAdUnitIdentifier: "«ad-unit-ID»")
rewardedAd.delegate = self
// Load the first ad
rewardedAd.load()
}
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd)
{
// Rewarded ad is ready to show. '[self.rewardedAd isReady]' now returns 'YES'.
// Reset retry attempt
retryAttempt = 0
}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds).
retryAttempt += 1
let delaySec = pow(2.0, min(6.0, retryAttempt))
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
self.rewardedAd.load()
}
}
func didDisplay(_ ad: MAAd) {}
func didClick(_ ad: MAAd) {}
func didHide(_ ad: MAAd)
{
// Rewarded ad is hidden. Pre-load the next ad
rewardedAd.load()
}
func didFail(toDisplay ad: MAAd, withError error: MAError)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
rewardedAd.load()
}
// MARK: MARewardedAdDelegate Protocol
func didRewardUser(for ad: MAAd, with reward: MAReward)
{
// Rewarded ad was displayed and user should receive the reward
}
}To show a rewarded ad, call showAd on the MARewardedAd object you retrieved.
if ( [self.rewardedAd isReady] )
{
[self.rewardedAd showAd];
}
if rewardedAd.isReady
{
rewardedAd.show()
}To prevent rewarded ad audio from interfering with your app’s background audio, AppLovin recommends that you stop your app’s background audio before you show an ad. You can then resume your app’s background audio after you hide the ad.
To access the reward amount and currency, override the -[MARewardedAdDelegate didRewardUserForAd:withReward:] callback:
- (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
{
NSLog(@"Rewarded user: %d %@", reward.amount, reward.label);
}
func didRewardUser(for ad: MAAd, with reward: MAReward)
{
print("Rewarded user: \(reward.amount) \(reward.label)")
}You can receive callbacks to your currency server. To learn how, see the MAX S2S rewarded callback API guide. Then update the Server Side Callback URL in your Edit Ad Unit page.
To set the reward amount and currency:

