Menu

Manual loading

1. Introduction

Manual loading mode can satisfy developers who need flexible access.

1.1 Integration suggestions

  1. Loading ads:
    • After the opening screen ad is displayed, Load ads by calling loadADWithPlacementID in advance to reduce user waiting time when displayed.
  2. Scene statistics:
    • It is recommended to call entryRewardedVideoScenarioWithPlacementID after entering the scene where the advertisement is displayed to count the number of usage scenarios of the current ad slot, specifically For statistical explanations, you can view Advertising Scenarios to distinguish data between different business scenarios.
  3. Display ads:
    • Call rewardedVideoReadyForPlacementID before displaying to determine whether the ad is ready
      • YES: You can call showRewardedVideoWithPlacementID for ad display;
      • NO: You need to decide whether to give up the impression and preload the next ad based on your needs. , or reload the ad and wait for it to be displayed after success.
  4. Next ad preload:
    • After the ad is displayed, you can start playing the callback rewardedVideoDidStartPlayingForPlacementID or close it Call loadADWithPlacementID in the callback of rewardedVideoDidCloseForPlacementID for preloading.
    • You can refer to Automatically request ads to enable automatic request for ads. If the preloading logic after display above has been implemented, Then automatic request does not need to be turned on, and vice versa.
  5. It is recommended to configure the preset strategy:

1.2 Notes:

    • It is forbidden to execute the ad loading method in the didFailToLoadADWithPlacementID callback, otherwise it will cause a lot of Useless request and may cause application lag
    • The userId passed in extra in the loading method, extraData will only be used next time and Subsequent rewarded video loading will take effect, but cached rewarded video ads will not take effect
    • Avoid displaying rewarded videos directly in the didFinishLoadingADWithPlacementID callback. If automatic ad requesting is enabled in the background, the SDK will automatically request ads after the ad is displayed, and developers cannot accurately control the timing of rewarded video display
    • It is not recommended when the App is in the background Download advertisements to avoid unnecessary exceptions caused by system recycling resources

2. API description

2.1 Loading ads

ATAdManager: Management class for rewarded video ads

MethodDescription
sharedManagerGet ATAdManager singleton Object
loadADWithPlacementID: extra: delegate:Loading rewarded video ads
placementId: Advertising slots need to be loaded automatically Id
extra: local parameter delegate: proxy object

Sample code display:

#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>

// load ad
  - (void)loadAd {
    // Set extra, custom parameters, will be sent back in the agent's Extra, can be used to match the custom rules of the AD space; 
    // When the server incentive video callback is enabled, set this value and then send it back to the developer when the incentive is sent.
    NSDictionary *extra = @{
          kATAdLoadingExtraMediaExtraKey:@"media_val",
          kATAdLoadingExtraUserIDKey:@"rv_test_user_id",
          kATAdLoadingExtraRewardNameKey:@"reward_Name",
          kATAdLoadingExtraRewardAmountKey:@(3)
      };
 
    [[ATAdManager sharedManager] loadADWithPlacementID:@"your rv placementId" extra:extra delegate:self];
}

2.2 Display Advertising

MethodDescription
rewardedVideoReadyForPlacementID:Determine whether there are currently ads that can be displayed
showRewardedVideoWithPlacementID: inViewController: delegate:Display this ad slot rewarded video ad
placementId: the ad slot Id to be displayed
inViewController: the viewController that displays the ad
delegate: proxy object
showRewardedVideoWithPlacementID: scene: inViewController: delegate:With scene id to display the rewarded video ad for this ad slot
placementId: the ad slot Id to be displayed
scene: scene id , if you do not differentiate between scenes, you can pass empty
inViewController: viewController for displaying ads
delegate: proxy object

Sample code display:

- (void)showRewardVideoAd {
    // Check if the AD is filled before display
    if ([[ATAdManager sharedManager] rewardedVideoReadyForPlacementID:@"your rv placementId"]) {
        // Ads filled, display ads
        [[ATAdManager sharedManager] showRewardedVideoWithPlacementID:@"your rv placementId" inViewController:self delegate:self];
    } else {
        // Unfilled AD
    }
}

2.3 Scene statistics

Statistics on the probability of users reaching the scene, and the data report presented in the background -> Funnel Analysis Report -> reaches the advertising scene, so it is recommended that developers call it in the right place.

MethodDescription
entryRewardedVideoScenarioWithPlacementID: scene:The corresponding advertising space enters the business scene cache status statistics
placementId: advertising space Id scene: advertising display
scene: the scene parameters can be created from the background, please refer to Business scenario cache status statistics
/*
     To collect scene arrival rate statistics, you can view related information https://docs.toponad.com/#/zh-cn/ios/NetworkAccess/scenario/scenario
     Call the "Enter AD scene" method when an AD trigger condition is met, such as:
     ** The scenario is a pop-up AD after the cleanup, which is called at the end of the cleanup.
     * 1、Call entryXXX to report the arrival of the scene.
     * 2、Call xxRewardedVideoReadyForPlacementID.
     * 3、Call showXX to show AD view.
     * (Note the difference between auto and manual)
     */
[[ATAdManager sharedManager] entryRewardedVideoScenarioWithPlacementID:@"your rv placement id" scene:@"your scenarioID"];
// Check if the AD is filled before display
if ([[ATAdManager sharedManager] rewardedVideoReadyForPlacementID:@"your rv placementId"]) {
    // Ad filled, showing ad
    [[ATAdManager sharedManager] showRewardedVideoWithPlacementID:@"your rv placementId" scene:@"your scenarioID" inViewController:self delegate:self];
} else {
    // Unfilled AD
}

2.4 Delegate callback

ATAdLoadingDelegate method

MethodDescription
didFinishLoadingADWithPlacementID:corresponds to advertising slot callback for successful ad loading
placementId: advertising slot Id
didFailToLoadADWithPlacementID: error:corresponds to advertising slot Advertising loading failure callback
placementId: Advertising slot Id
error: Advertising loading failure information
didStartLoadingADSourceWithPlacementID: extra:Callback placementId corresponding to An advertising source in the advertising slot starts loading ads:
PlacementID: Advertising slot Id
extra: Advertising additional parameters
didFinishLoadingADSourceWithPlacementID: extra:corresponds to an advertising source in the advertising slot Callback placementId for successful advertisement loading:
PlacementID: Advertising slot Id
extra: Advertising additional parameters
didFailToLoadADSourceWithPlacementID: extra: error:Failed to load ads corresponding to a certain advertising source in the advertising slot callback
PlacementId: ad slot Id
extra: ad additional parameters
error: ad loading failure information
didStartBiddingADSourceWithPlacementID: extra:Corresponds to A certain advertising source in the advertising slot bids ads Callback to start bidding
placementId: Advertising slot Id
extra: Advertisement Additional parameters
didFinishBiddingADSourceWithPlacementID: extra:corresponds to an ad source in the ad slot bids for ads Callback placementId for successful bidding.
placementId: ad slot Id
extra: ad additional parameters
didFailBiddingADSourceWithPlacementID: extra: error:corresponds toa bidding advertisement from a certain advertising source in the advertising slot Bidding Failed callback placementId: Advertising slot Id
extra: Advertising additional parameters
error: Bidding ad failure information

ATRewardedVideoDelegate method

MethodCallback function meaning
rewardedVideoDidRewardSuccessForPlacemenID: extra:Incentive video advertising rewards are issued
rewardedVideoDidStartPlayingForPlacementID: extra:Incentive The video ad playback starts, that is, the incentive video display callback
rewardedVideoDidEndPlayingForPlacementID: extra:Rewarded video ad play ends
rewardedVideoDidFailToPlayForPlacementID: error: extra:Rewarded video ad play failed
rewardedVideoDidClickForPlacementID: extra:Rewarded video ad clicks
rewardedVideoDidCloseForPlacementID: rewarded: extra:Rewarded video ads off
rewardedVideoDidDeepLinkOrJumpForPlacementID: extra: result:Rewarded video ads click to jump Whether it is in Deeplink form, currently only returned for TopOn Adx ads
extra: Extended parameter reference Documentation

Note: Only TT(CSJ) supports VideoAgainDelegate

MethodCallback function meaning
rewardedVideoAgainDidStartPlayingForPlacementID: extra:Rewarded video ad to watch again ad playback begins
rewardedVideoAgainDidEndPlayingForPlacementID: extra:Rewarded video ad to watch again ad play ends
rewardedVideoAgainDidFailToPlayForPlacementID: extra:rewarded video Watch the ad again and the ad playback failed
rewardedVideoAgainDidClickForPlacementID : extra:Rewarded video ad to watch again ad click
rewardedVideoAgainDidRewardSuccessForPlacemenID: extra:Rewarded video ads to watch the ads again
extra:Extended parameter reference Documentation

Sample code display :

#pragma mark - loading delegate
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--AD--Start--ATRewardVideoViewController::didStartLoadingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--AD--Finish--ATRewardVideoViewController::didFinishLoadingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error {
    NSLog(@"ADSource--AD--Fail--ATRewardVideoViewController::didFailToLoadADSourceWithPlacementID:%@---error:%@", placementID,error);
}

// bidding
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--bid--Start--ATRewardVideoViewController::didStartBiddingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--bid--Finish--ATRewardVideoViewController::didFinishBiddingADSourceWithPlacementID:%@--extra:%@", placementID,extra);
}

- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error {
    NSLog(@"ADSource--bid--Fail--ATRewardVideoViewController::didFailBiddingADSourceWithPlacementID:%@--error:%@", placementID,error);
}

-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
    NSLog(@"PlacementID--load--Finish--ATRewardedVideoViewController::didFinishLoadingADWithPlacementID:%@", placementID);
}

-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
    NSLog(@"PlacementID--load--Fail--ATRewardedVideoViewController::didFailToLoadADWithPlacementID:%@ error:%@", placementID, error);
}

#pragma mark - showing delegate
-(void) rewardedVideoDidRewardSuccessForPlacemenID:(NSString *)placementID extra:(NSDictionary *)extra{
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidRewardSuccessForPlacemenID:%@ extra:%@",placementID,extra);
}

-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
    [self showLog:[NSString stringWithFormat:@"rewardedVideoDidStartPlaying:%@", placementID]];
}

-(void) rewardedVideoDidEndPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidEndPlayingForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoDidFailToPlayForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidFailToPlayForPlacementID:%@ error:%@ extra:%@", placementID, error, extra);
}

-(void) rewardedVideoDidCloseForPlacementID:(NSString*)placementID rewarded:(BOOL)rewarded extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidCloseForPlacementID:%@, rewarded:%@ extra:%@", 
        placementID, rewarded ? @"yes" : @"no", extra);
}

-(void) rewardedVideoDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidClickForPlacementID:%@ extra:%@", placementID, extra);
}

- (void)rewardedVideoDidDeepLinkOrJumpForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
    NSLog(@"ATRewardedVideoViewController:: rewardedVideoDidDeepLinkOrJumpForPlacementID:placementID:%@ with extra: %@, success:%@", 
        placementID,extra, success ? @"YES" : @"NO");
}

// rewarded video again (only TT(CSJ))
-(void) rewardedVideoAgainDidStartPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidEndPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidEndPlayingForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidFailToPlayForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidFailToPlayForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidClickForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidRewardSuccessForPlacemenID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidRewardSuccessForPlacemenID:%@ extra:%@", placementID, extra);
}

2.5 Set server callback Parameters

MethodTypeDescription
kATAdLoadingExtraUserIDKeyNSString(optional) used for server incentives, user unique ID
kATAdLoadingExtraMediaExtraKeyNSString(optional) used for server incentives, user-defined data
kATAdLoadingExtraRewardNameKeyNSString(optional) used for server incentives, reward name
kATAdLoadingExtraRewardAmountKeyNSNumber(optional) used for server incentives, reward amount
// Set extra, custom parameters, will be sent back in the agent's Extra, can be used to match the custom rules of the AD space;  
// When the server incentive video callback is enabled, set this value and then send it back to the developer when the incentive is sent.
  NSDictionary *extra = @{
        kATAdLoadingExtraMediaExtraKey:@"media_val", 
        kATAdLoadingExtraUserIDKey:@"rv_test_user_id",
        kATAdLoadingExtraRewardNameKey:@"reward_Name",
        kATAdLoadingExtraRewardAmountKey:@(3)
    };
  // load Reward ad
  [[ATAdManager sharedManager] loadADWithPlacementID:@"your rv placementId" extra:extra delegate:self];

2.6 Other APIs

MethodDescription
getRewardedVideoValidAdsForPlacementID:Query all cached information of this ad slot. The first item in the array is the ad data to be displayed.
placementId: the advertising slot Id to be queried
// Query all cache information for the placement id
 NSArray *array = [[ATAdManager sharedManager] getRewardedVideoValidAdsForPlacementID:@"your rv placementID"];
 NSLog(@"ValidAds.count:%ld--- ValidAds:%@",array.count,array);

3. Sample code

#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>

@interface ATRewardVideoViewController () <ATAdLoadingDelegate, ATRewardedVideoDelegate>
@end

@implementation ATRewardVideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadAd];
}

  - (void)loadAd {
    // Set extra, custom parameters, will be sent back in the agent's Extra, can be used to match the custom rules of the AD space;  
    // When the server incentive video callback is enabled, set this value and then send it back to the developer when the incentive is sent.
    NSDictionary *extra = @{
          kATAdLoadingExtraMediaExtraKey:@"media_val",
          kATAdLoadingExtraUserIDKey:@"rv_test_user_id",
          kATAdLoadingExtraRewardNameKey:@"reward_Name",
          kATAdLoadingExtraRewardAmountKey:@(3)
      };
    // load rewarded ads
    [[ATAdManager sharedManager] loadADWithPlacementID:@"your rv placementId" extra:extra delegate:self];
}

- (void)entryAdScenario {

    /* To collect scene arrival rate statistics, you can view related information https://docs.toponad.com/#/zh-cn/ios/NetworkAccess/scenario/scenario 
    Call the "Enter AD scene" method when an AD trigger condition is met, 
    such as: ** The scenario is a pop-up AD after the cleanup, 
    which is called at the end of the cleanup. 
    * 1、Call entryXXX to report the arrival of the scene. 
    * 2、Call xxRewardedVideoReadyForPlacementID. 
    * 3、Call showXX to show AD view. 
    * (Note the difference between auto and manual) */
    [[ATAdManager sharedManager] entryRewardedVideoScenarioWithPlacementID:@"your rv placement id" scene:@"your scenarioID"];
}

- (void)showRewardVideoAd {
    
    [self entryAdScenario];
    
     // Check if the AD is filled before display
    if ([[ATAdManager sharedManager] rewardedVideoReadyForPlacementID:@"your rv placementId"]) {
 
        [[ATAdManager sharedManager] showRewardedVideoWithPlacementID:@"your rv placementId" scene:@"your scenarioID" inViewController:self delegate:self];
    } else {
 
    }
}

#pragma mark - loading delegate
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--AD--Start--ATRewardVideoViewController::didStartLoadingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--AD--Finish--ATRewardVideoViewController::didFinishLoadingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error {
    NSLog(@"ADSource--AD--Fail--ATRewardVideoViewController::didFailToLoadADSourceWithPlacementID:%@---error:%@", placementID,error);
}

// bidding
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--bid--Start--ATRewardVideoViewController::didStartBiddingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"ADSource--bid--Finish--ATRewardVideoViewController::didFinishBiddingADSourceWithPlacementID:%@--extra:%@", placementID,extra);
}

- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error {
    NSLog(@"ADSource--bid--Fail--ATRewardVideoViewController::didFailBiddingADSourceWithPlacementID:%@--error:%@", placementID,error);
}

-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
    NSLog(@"ADSource--load--Finish--ATRewardedVideoViewController::didFinishLoadingADWithPlacementID:%@", placementID);
}

-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
    NSLog(@"placementID--load--Fail--ATRewardedVideoViewController::didFailToLoadADWithPlacementID:%@ error:%@", placementID, error);
}

#pragma mark - showing delegate
-(void) rewardedVideoDidRewardSuccessForPlacemenID:(NSString *)placementID extra:(NSDictionary *)extra{
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidRewardSuccessForPlacemenID:%@ extra:%@",placementID,extra);
}

-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
    [self showLog:[NSString stringWithFormat:@"rewardedVideoDidStartPlaying:%@", placementID]];
}

-(void) rewardedVideoDidEndPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidEndPlayingForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoDidFailToPlayForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidFailToPlayForPlacementID:%@ error:%@ extra:%@", placementID, error, extra);
}

-(void) rewardedVideoDidCloseForPlacementID:(NSString*)placementID rewarded:(BOOL)rewarded extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidCloseForPlacementID:%@, rewarded:%@ extra:%@", placementID, rewarded ? @"yes" : @"no", extra);
}

-(void) rewardedVideoDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoDidClickForPlacementID:%@ extra:%@", placementID, extra);
}

- (void)rewardedVideoDidDeepLinkOrJumpForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
    NSLog(@"ATRewardedVideoViewController:: rewardedVideoDidDeepLinkOrJumpForPlacementID:placementID:%@ with extra: %@, success:%@", placementID,extra, success ? @"YES" : @"NO");
}

// rewarded video again (only TT(CSJ) )
-(void) rewardedVideoAgainDidStartPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidEndPlayingForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidEndPlayingForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidFailToPlayForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidFailToPlayForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidClickForPlacementID:%@ extra:%@", placementID, extra);
}

-(void) rewardedVideoAgainDidRewardSuccessForPlacemenID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"ATRewardedVideoViewController::rewardedVideoAgainDidRewardSuccessForPlacemenID:%@ extra:%@", placementID, extra);
}

@end

Detailed rewarded video advertising please refer to the sample code: Demo ATRewardVideoViewController classes.

Last modified: 2025-05-30Powered by