Menu

Rewarded Video Ads

1. Integration Recommendations

1.1 Showing Rewarded Video Ads

  • It is recommended to check if the ad is ready before showing, and proceed with the display operation only after it is ready
  • If you need to show ads in the ad placement loading success callback (didFinishLoadingADWithPlacementID), you must first check (UIApplicationState==UIApplicationStateActive) before executing the show method, otherwise it may cause the ad to not display properly and affect revenue.

1.2 Ad Preloading

  • You can call the loading method to request ads in advance of the display scenario (for example, start loading ads when UIApplicationState==UIApplicationStateActive after the app starts), so that when you reach the scenario where you need to show ads, you can display them quickly

1.3 Server Callback

  • Rewarded video supports server callback reward distribution mechanism, and also supports server callback functions of various ad platforms. Please refer to Server-side Rewards

1.4 Sample Code

  • For detailed rewarded video ad sample code, please refer to: RewardedVC.m in Demo

The extra dictionary in this step supports passing in relevant parameters for configuring ads and your custom parameters. You can view more information about extra parameters here.

objc Copy
//Import header file
#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>

@interface RewardedVC () <ATAdLoadingDelegate, ATRewardedVideoDelegate>

@property (nonatomic, assign) NSInteger retryAttempt; // Retry attempt counter

@end

@implementation RewardedVC

//Ad placement ID
#define RewardedPlacementID @"b67f4ab93eb3a7"

//Scene ID, optional, can be generated in the backend. If not available, pass an empty string
#define RewardedSceneID @""

#pragma mark - Load Ad
- (void)loadAd {

    NSMutableDictionary * loadConfigDict = [NSMutableDictionary dictionary];
    // Optional integration, the following key parameters are applicable to server-side reward verification of ad platforms and will be passed through
    [loadConfigDict setValue:@"media_val_RewardedVC" forKey:kATAdLoadingExtraMediaExtraKey];
    [loadConfigDict setValue:@"rv_test_user_id" forKey:kATAdLoadingExtraUserIDKey];
    [loadConfigDict setValue:@"reward_Name" forKey:kATAdLoadingExtraRewardNameKey];
    [loadConfigDict setValue:@3 forKey:kATAdLoadingExtraRewardAmountKey];
     
    // Start ad loading
    [[ATAdManager sharedManager] loadADWithPlacementID:RewardedPlacementID extra:loadConfigDict delegate:self];
}

/// Ad placement loading completed
/// - Parameter placementID: Ad placement ID
- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
    // Reset retry attempts
    self.retryAttempt = 0;
}
 
/// Ad placement loading failed
/// - Parameters:
///   - placementID: Ad placement ID
///   - error: Error information
- (void)didFailToLoadADWithPlacementID:(NSString *)placementID error:(NSError *)error { 
    if (self.retryAttempt >= 3) {
       return;
    }
    self.retryAttempt++;
    
    // Calculate delay time: power of 2, maximum 8 seconds
    NSInteger delaySec = pow(2, MIN(3, self.retryAttempt));

    // Delayed retry loading ad
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        [self loadAd];
    });
}
  • The showCustomExt field of ATShowConfig in the show method also supports server callbacks. You need to add &ilrd={ilrd} to the reward callback address configured in the backend, and then the server can parse the show_custom_ext field. When you use showCustomExt as server-side rewards, the extra parameters when loading ads must include parameters for server callbacks (please refer to the example in the loading ads section above), otherwise the server will not receive callbacks.
  • Statistics scene arrival rate, displayed in the backend's Data Reports -> Funnel Analysis Report -> Arrival at Ad Scene, called before showing ads.
objc Copy
#pragma mark - Show Ad
/// Show ad
- (void)showAd {
    
    //Scene statistics function, displayed in the backend's Data Reports -> Funnel Analysis Report -> Arrival at Ad Scene, called before showing ads. Optional integration
    [[ATAdManager sharedManager] entryRewardedVideoScenarioWithPlacementID:RewardedPlacementID scene:RewardedSceneID];

    //Check if ready
    if (![[ATAdManager sharedManager] rewardedVideoReadyForPlacementID:RewardedPlacementID]) {
        [self loadAd];
        return;
    }
    
    //Show configuration, Scene passes in the backend scene ID, if not available pass an empty string, showCustomExt parameter can pass in custom parameter string
    ATShowConfig *config = [[ATShowConfig alloc] initWithScene:RewardedSceneID showCustomExt:@"testShowCustomExt"];
 
    //Show ad
    [[ATAdManager sharedManager] showRewardedVideoWithPlacementID:RewardedPlacementID config:config inViewController:self delegate:self];
}

#pragma mark - ATRewardedVideoDelegate
/// Reward success
/// - Parameters:
///   - placementID: Ad placement ID
///   - extra: Extra information dictionary
- (void)rewardedVideoDidRewardSuccessForPlacemenID:(NSString *)placementID extra:(NSDictionary *)extra {}

/// Rewarded ad video started playing
/// - Parameters:
///   - placementID: Ad placement ID
///   - extra: Extra information dictionary
- (void)rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {}
 
/// Rewarded ad video finished playing
/// - Parameters:
///   - placementID: Ad placement ID
///   - extra: Extra information dictionary
- (void)rewardedVideoDidEndPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {}

/// Rewarded ad video failed to play
/// - Parameters:
///   - placementID: Ad placement ID
///   - error: Error information
///   - extra: Extra information dictionary
- (void)rewardedVideoDidFailToPlayForPlacementID:(NSString*)placementID error:(NSError *)error extra:(NSDictionary *)extra {
     // Preload
    [self loadAd];
}

/// Rewarded ad closed
/// - Parameters:
///   - placementID: Ad placement ID
///   - rewarded: Whether reward was successful, YES means reward success callback has been triggered
///   - extra: Extra information dictionary
- (void)rewardedVideoDidCloseForPlacementID:(NSString *)placementID rewarded:(BOOL)rewarded extra:(NSDictionary *)extra {
    // Preload
    [self loadAd];
}
 
/// Rewarded ad was clicked
/// - Parameters:
///   - placementID: Ad placement ID
///   - extra: Extra information dictionary
- (void)rewardedVideoDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {}

/// Rewarded ad opened or jumped to deep link page
/// - Parameters:
///   - placementID: Ad placement ID
///   - extra: Ad placement ID
///   - success: Whether successful
- (void)rewardedVideoDidDeepLinkOrJumpForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {}

4. Reward Distribution

Through registering the following delegate method in ATRewardedVideoDelegate

objc Copy
/// Reward distribution
- (void)rewardedVideoDidRewardSuccessForPlacemenID:(NSString *)placementID extra:(NSDictionary *)extra {
}

5. Advanced

Fully automatic loading : TopOn has launched a one-stop solution that intelligently determines the timing for preloading and caching the next ad based on the user's usage status and the progress of ad consumption.

Previous
AD Formats
Next
Interstitial Ads
Last modified: 2025-07-31Powered by