Menu

Rewarded video

You have already added and configured a custom ad platform in the TopOn backend. If you have not done so yet, please go here.

The following example is a non-bidding ad implementation. For a custom ad platform to implement bidding, please refer here.

1. Create the Adapter Class

Based on the Rewarded Video class name you added in the TopOn backend, create the RewardedVideoAdapter class (named CustomRewardedVideoAdapter in this example).

Copy
// CustomRewardedVideoAdapter.h

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface CustomRewardedVideoAdapter : NSObject

@end

NS_ASSUME_NONNULL_END
Copy
// CustomRewardedVideoAdapter.m

#import "CustomRewardedVideoAdapter.h"

@interface CustomRewardedVideoAdapter ()
 
@end

@implementation CustomRewardedVideoAdapter

@end

2. Conform to and Implement the ATAdAdapter Protocol

Make the CustomRewardedVideoAdapter class created in the previous step conform to the ATAdAdapter protocol and implement its required methods.

To view more information about the ATAdAdapter protocol, please click here.

Copy
#import "CustomRewardedVideoAdapter.h"
#import <AnyThinkSDK/AnyThinkSDK.h>
#import <AnyThinkRewardedVideo/ATRewardedVideo.h>

@interface CustomRewardedVideoAdapter() <ATAdAdapter>

@end

@implementation CustomRewardedVideoAdapter

/// Must be implemented, used to initialize the custom adapter. Non-bidding ads enter here; for bidding ads, please refer to the documentation.
/// - Parameters:
///   - serverInfo: the parameter dictionary configured on the server
///   - localInfo: the parameter dictionary passed in for this load
- (instancetype)initWithNetworkCustomInfo:(NSDictionary*)serverInfo localInfo:(NSDictionary*)localInfo {
    self = [super init];
    if (self != nil) {
        // Add your ad SDK initialization method here
    }
    return self;
}


/// Must be implemented, the logic for the custom ad platform to load ads
/// - Parameters: implement the logic for the custom ad platform to load ads
///   - serverInfo: the parameter dictionary configured on the server
///   - localInfo: the parameter dictionary passed in for this load
///   - completion: completion callback
- (void)loadADWithInfo:(NSDictionary*)serverInfo localInfo:(NSDictionary*)localInfo completion:(void (^)(NSArray<NSDictionary *> *, NSError *))completion {
    
    // Load the ad
}


/// Must be implemented, used to determine whether the custom ad platform's Rewarded Video ad is ready (or within the ad's validity period)
/// - Parameters:
///   - customObject: the custom ad object
///   - info: the parameter dictionary configured on the server
+ (BOOL)adReadyWithCustomObject:(id)customObject info:(NSDictionary*)info {
    
    BOOL flag = YES;
    //Logic for whether the ad is ready
    
    return flag;
}

/// Implement the logic for displaying the custom ad platform's Rewarded Video
/// - Parameters:
///   - rewardedVideo: the Rewarded Video object
///   - viewController: the current view controller
///   - delegate: the ad object delegate
+ (void)showRewardedVideo:(ATRewardedVideo*)rewardedVideo inViewController:(UIViewController*)viewController delegate:(id) delegate {
    
    // Show the ad
    
}
  
@end

3. Create the Ad Callback CustomEvent Class

Implement a custom CustomEvent class (named RewardedVideoCustomEvent in this example) that inherits from the ATRewardedVideoCustomEvent class. Through this class, add the callback delegates corresponding to the custom ad platform. When the third-party ad platform has a callback, call the event methods you defined in this class. In these event methods you defined, you need to call the methods inherited from ATRewardedVideoCustomEvent to pass the events back to the TopOn iOS SDK. This example only demonstrates the Rewarded Video load-completed callback; add the other methods yourself.

Please click here to view the detailed description of the ATRewardedVideoCustomEvent class.

Before delivering the reward callback to the user, the TopOn SDK pass-back method needs the rewardGranted parameter to be set to YES, to indicate whether the reward has already been delivered.

Copy
//RewardedVideoCustomEvent.h

#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>

NS_ASSUME_NONNULL_BEGIN

@interface RewardedVideoCustomEvent : ATRewardedVideoCustomEvent

@end

NS_ASSUME_NONNULL_END
Copy
@implementation RewardedVideoCustomEvent
  
/// Your ad platform SDK's Rewarded Video load-completed callback. For the specific method name and parameters, please check your ad platform SDK documentation
- (void)your3rdSDKRewardedVideoAdDidLoad:(id)rewardedVideoAd {
    ...
    //Pass the info back to the TopOn iOS SDK
    [self trackRewardedVideoAdLoaded:rewardedVideoAd adExtra:nil];
}

...
Other methods that need to be passed back

@end
Previous
Implementing Bidding for Custom Ads
Next
Interstitials
Last modified: 2026-07-09Powered by