Loading 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;
@implementation ExampleViewController
self . rewardedAd = [MARewardedAd sharedWithAdUnitIdentifier : @" «ad-unit-ID» " ];
self . rewardedAd . delegate = self ;
[ self .rewardedAd loadAd ];
#pragma mark - MAAdDelegate Protocol
- ( void ) didLoadAd : (MAAd * ) ad
// Rewarded ad is ready to show. '[self.rewardedAd isReady]' now returns 'YES'
- ( 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)
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
class ExampleViewController : UIViewController , MARewardedAdDelegate
var rewardedAd: MARewardedAd !
rewardedAd = MARewardedAd. shared ( withAdUnitIdentifier : " «ad-unit-ID» " )
rewardedAd. delegate = self
// MARK: MAAdDelegate Protocol
// Rewarded ad is ready to show. '[self.rewardedAd isReady]' now returns 'YES'.
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).
let delaySec = pow ( 2.0 , min ( 6.0 , retryAttempt ))
DispatchQueue. main . asyncAfter ( deadline : . now () + delaySec ) {
func didDisplay ( _ ad : MAAd ) {}
func didClick ( _ ad : MAAd ) {}
// Rewarded ad is hidden. Pre-load the next ad
func didFail ( toDisplay ad : MAAd, withError error : MAError )
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
// MARK: MARewardedAdDelegate Protocol
func didRewardUser ( for ad : MAAd, with reward : MAReward )
// Rewarded ad was displayed and user should receive the reward
Showing a Rewarded Ad
To show a rewarded ad, call showAd
on the MARewardedAd
object you retrieved.
if ( [ self .rewardedAd isReady ] )
[ self .rewardedAd showAd ];
Accessing the Amount and Currency for a Rewarded 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 ) " )
S2S Rewarded Callbacks
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.
Setting the Amount and Currency for a Rewarded Ad
To set the reward amount and currency:
Click Add S2S Reward Callback in your Edit Ad Unit page:
Add the Server Side Callback URL , Reward Amount , and Rewarded Currency Name :