Menu

Fully automatic loading

1. Introduction

Fully automatic loading mode is a one-stop request maintenance solution launched by TopOn, developed Users only need to pay attention to the timing of loading and display calls, reducing the cost of access time.

1.1 Integration suggestions

  1. Loading ads:
    • It is recommended that after the opening screen advertisement is displayed Call addAutoLoadAdPlacementIDArray to load fully automatic rewarded video ads , if you need to set the proxy and pass in localExtra, please set it before calling the automatic loading method.
  2. Scene statistics:
    • It is recommended to call entryAdScenarioWithPlacementID after entering the display advertising scene to count the cache status of the current ad slot. , for specific statistical explanations, please view Advertising Scenarios to distinguish data between different business scenarios.
  3. Display ads:
    • Before displaying, you need to call autoLoadRewardedVideoReadyForPlacementID to determine whether the ad is ready
      • YES: Can be called directly showAutoLoadRewardedVideoWithPlacementID display advertising.
      • NO: Skip this impression opportunity, and the SDK will load the ad to fill it.
  4. Server callback parameters:
    • If you need to support the server callback to pass in userId and extraData, please add the specific advertising slot to enter the automatic loading mode Call the setLocalExtra method in the didFinishLoadingADWithPlacementID callback before and during ad loading to pass in custom parameters. Please refer to the sample code.

1.2 Notes:

    • Fully automatic incentive video implements automatic loading logic internally, and will call back to didFinishLoadingADWithPlacementID after successful loading, so please avoid directly executing ad display in the didFinishLoadingADWithPlacementID callback to cause a loop In the case of display, if the ad slot is set to fully automatic loading, do not call loadADWithPlacementID to load the ad
    • In the loading method extra The userId and extraData passed in will only take effect for the next and subsequent rewarded video loads, and will not take effect for cached rewarded video ads
    • It is not recommended to load ads when the App is in the background to avoid unnecessary exceptions caused by system recycling of resources

2. API description

2.1 Loading ads

ATRewardedVideoAutoAdManager: Fully automatic loading management class for rewarded video ads

MethodDescription
sharedInstanceGet ATRewardedVideoAutoAdManager singleton object
addAutoLoadAdPlacementIDArray:Add advertising slots that need to be loaded automatically
placementIds: Advertising slot Id arrays that need to be loaded automatically

Sample code:

#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>

// setting delegate
[ATRewardedVideoAutoAdManager sharedInstance].delegate = self;    

[[ATRewardedVideoAutoAdManager sharedInstance] addAutoLoadAdPlacementIDArray:@[@"your rv placementID"]]; 

2.2 Display advertising

MethodDescription
autoLoadRewardedVideoReadyForPlacementID:Determine whether the ad slot exists and can be displayed Advertisement
placementId: Advertising slot Id to be queried
showAutoLoadRewardedVideoWithPlacementID: 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
showAutoLoadRewardedVideoWithPlacementID: scene: inViewController: delegate:Pass in the 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 it empty
inViewController: viewController that displays ads
delegate: proxy object

Sample code:

- (void)showAd {
    // Check to see if the AD is ready before showing
    if ([[ATRewardedVideoAutoAdManager sharedInstance] autoLoadRewardedVideoReadyForPlacementID:@"your rv placement id"]) {
        
        [[ATRewardedVideoAutoAdManager sharedInstance] showAutoLoadRewardedVideoWithPlacementID:@"your rv placement id" inViewController:self delegate:self];
    } 
}

2.3 Scene statistics

Statistics on the probability of users reaching the scene, displayed in the background Data report-> Funnel analysis report-> reaches the advertising scene, so it is recommended that developers call it in the right place.

MethodDescription
entryAdScenarioWithPlacementID: scenarioID:The corresponding advertising slot enters the business scenario cache status statistics placementId: Advertising slot Id scenario: Ad display scenario, the scenario 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) */
[[ATRewardedVideoAutoAdManager sharedInstance] entryAdScenarioWithPlacementID:@"your rv placement id" scenarioID:@"your scenarioID"];
// Check to see if the AD is ready before showing
if ([[ATRewardedVideoAutoAdManager sharedInstance] autoLoadRewardedVideoReadyForPlacementID:@"your rv placement id"]) {
     
      [[ATRewardedVideoAutoAdManager sharedInstance] showAutoLoadRewardedVideoWithPlacementID:@"your rv placement id" scene:@"your scenarioID" inViewController:self delegate:self];
}

2.4 Delegate callback

ATAdLoadingDelegate delegate method

MethodDescription
didFinishLoadingADWithPlacementID:Corresponds to Advertising slot advertisement Loading success callback
placementId: Advertising slot Id
didFailToLoadADWithPlacementID: error:corresponds Advertising slot advertisement Loading failure callback
placementId: Advertising slot Id
error: Advertisement loading failure information
didStartLoadingADSourceWithPlacementID: extra:corresponds An advertising source in the advertising slot Callback to start loading ads
placementId: Advertising slot Id
extra: Advertising additional parameters
didFinishLoadingADSourceWithPlacementID: extra:Corresponds to Callback for a certain advertising source in the advertising slot when the advertisement is loaded successfully
placementId: Advertising slot Id
extra: Advertising additional parameters
didFailToLoadADSourceWithPlacementID: extra: error:Corresponds to Callback for failure to load ads from an advertising source in the advertising slot
placementId: Advertisement slot Id
extra: Advertising additional parameters
error: Ad loading failure information
didStartBiddingADSourceWithPlacementID: extra:corresponds to a certain advertising source in the advertising slot Callback for bidding start bidding
placementId: Advertising slot Id
extra: Advertising additional parameters
didFinishBiddingADSourceWithPlacementID: extra:corresponds to advertising slot Callback for successful advertising bidding for an advertising source
placementId: Advertising slot Id
extra: Advertising additional parameters
didFailBiddingADSourceWithPlacementID: extra: error:corresponds to An advertising source in the advertising slot Callback for failed advertising bidding
placementId: Advertising slot Id
extra: Advertising additional parameters
error: Bidding advertising failure information

ATRewardedVideoDelegate delegate method

MethodDescription
rewardedVideoDidRewardSuccessForPlacemenID: extra:rewardedVideoDidRewardSuccess
rewardedVideoDidStartPlayingForPlacementID: extra:The rewarded video ad playback starts, that is, the rewarded 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 are closed
rewardedVideoDidDeepLinkOrJumpForPlacementID: extra: result:Whether the rewarded video ad click jump is Deeplink form, currently only returned for TopOn Adx ads
extra: Extended parameter reference Documentation

Note: TT(CSJ) only Support VideoAgainDelegate

Callback function name Callback 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 ads to watch again ads failed
rewardedVideoAgainDidClickForPlacementID: extra:Rewarded video ads to watch ads again
rewardedVideoAgainDidRewardSuccessForPlacemenID: extra:Rewarded video Watch the ad again and send the ad incentive
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(@"placement id--Load--Finish--ATRewardedVideoViewController::didFinishLoadingADWithPlacementID:%@", placementID);
}

-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
    NSLog(@"placement id--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);
}

-(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
-(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

methodDescription
sharedInstanceGet ATRewardedVideoAutoAdManager singleton object
setLocalExtra: placementID:Set local parameters for the specified ad slot
placementId: ad slot Id
localExtra: local parameters

LocalExtraLocal parameter predefined Key value

MethodType Description
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

Sample code display:

[[ATRewardedVideoAutoAdManager sharedInstance] setLocalExtra:
  @{kATAdLoadingExtraUserIDKey:@"test_user_id"} placementID:@"your rv placementID"]; 

2.6 Others API

MethodDescription
removeAutoLoadAdPlacementIDArray:Remove ads without fully automatic loading Position
placementIds: No need to automatically load the advertising slot Id array
checkValidAdCachesWithPlacementID: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

Sample code display:

    // Query all cache information for the AD space
     NSArray *array = [[ATRewardedVideoAutoAdManager sharedManager] checkValidAdCachesWithPlacementID:@"your rv placementID"];
     NSLog(@"ValidAds.count:%ld--- ValidAds:%@",array.count,array);
    
    // Remove autoload
    [[ATRewardedVideoAutoAdManager sharedInstance] removeAutoLoadAdPlacementIDArray:@[]];

3. Sample code

#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h> 

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

@implementation ATRewardVideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [ATRewardedVideoAutoAdManager sharedInstance].delegate = self;
 
    [[ATRewardedVideoAutoAdManager sharedInstance] setLocalExtra:@{kATAdLoadingExtraUserIDKey:@"test_user_id"} placementID:@"your rv placementID"];
    [[ATRewardedVideoAutoAdManager sharedInstance] addAutoLoadAdPlacementIDArray:@[@"your rv placementID"]];
}

- (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) */
    [[ATRewardedVideoAutoAdManager sharedInstance] entryAdScenarioWithPlacementID:@"your rv placement id" scenarioID:@"your scenarioID"];
}

- (void)showAd {
 
     [self entryAdScenario];
     
    // Check to see if the AD is ready before showing
    if ([[ATRewardedVideoAutoAdManager sharedInstance] autoLoadRewardedVideoReadyForPlacementID:@"your rv placement id"]) {
     
        [[ATRewardedVideoAutoAdManager sharedInstance] showAutoLoadRewardedVideoWithPlacementID:@"your rv placement id" scene:@"your scenarioID" inViewController:self delegate:self];
    } 
}

#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(@"placement ID--Load--Finish--ATRewardedVideoViewController::didFinishLoadingADWithPlacementID:%@", placementID);
}

-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
    NSLog(@"placement ID--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);
}

-(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
-(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