Integration
Ad loading
- If the ad slot is set to fully automatic loading, do not call ATAdManager (normal ad loading class) loadADWithPlacementID: Method to load ads
- It is recommended to initialize the fully automatic rewarded video ads on the main page
Advertising display
- Before displaying, check whether autoLoadRewardedVideoReadyForPlacementID: is ready. If it is ready, call the display API to display the ad. If it is not ready, initiate ad loading and wait for the ad to load successfully.
- Before displaying, you need to first determine whether the current application is in the foreground . If you call the display API in the background, the ad may be displayed outside the application or may not be displayed normally.
- The fully automatic rewarded video implements automatic loading logic internally, so please avoid directly executing ad display in the didFinishLoadingADWithPlacementID: callback
Server callback
- Fully automatic loading of rewarded videos supports the incentive distribution mechanism of server callback (S2S), and also supports the server callback function of various advertising platforms. Please refer to the description of rewarded video server reward (S2S)
Loading Ads
#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>
- (void)loadAutoRewardedVideo {
[ATRewardedVideoAutoAdManager sharedInstance].delegate = self;
/*
Setting extra custom parameters will be sent back to the Extra of the agent, which 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.
*/
[[ATRewardedVideoAutoAdManager sharedInstance] setLocalExtra:
@{kATAdLoadingExtraUserIDKey:@"test_user_id"} placementID:@"your rv placementID"];
[[ATRewardedVideoAutoAdManager sharedInstance] addAutoLoadAdPlacementIDArray:@[@"your rv placementID"]];
}
- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
BOOL ready = [[ATAdManager sharedManager] rewardedVideoReadyForPlacementID:placementID];
NSLog(@"ATRewardVideoViewController::didFinishLoadingADWithPlacementID:%@--isReady:%@", placementID, ready ? @"YES":@"NO");
}
- (void)didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
NSLog(@"didFailToLoadADWithPlacementID:%@ errorCode:%ld", placementID, (long)error.code);
}
Notice:
- For the same ad slot ID, you only need to call the fully automatic loading API once.
Display ads
- (void)showAd {
// Determine if the AD is filled before display
if ([[ATRewardedVideoAutoAdManager sharedInstance] autoLoadRewardedVideoReadyForPlacementID:@"your rv placement id"]) {
// show ad
[[ATRewardedVideoAutoAdManager sharedInstance] showAutoLoadRewardedVideoWithPlacementID:@"your rv placement id" inViewController:self delegate:self];
}
}
#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);
/*
Setting extra custom parameters will be sent back to the Extra of the agent, which 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.
Special note: If you use the tripartite incentive video server callback service, due to the advertising caching function within our SDK, the incoming extension parameters may not be able to change the effect in real time, so if there is such a need
Please use the incentive video server callback service provided by us and set the corresponding extension parameters in the displayed API (you need to use the ordinary incentive video loading method).
*/
[[ATRewardedVideoAutoAdManager sharedInstance] setLocalExtra:
@{kATAdLoadingExtraUserIDKey:@"test_user_id"} placementID:@"your rv 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 CSJ support.
-(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);
}
API Description
ATRewardedVideoAutoAdManager
Automatic loading of rewarded video ads management class
method | illustrate |
---|---|
sharedInstance | Get the ATRewardedVideoAutoAdManager singleton object |
delegate | Set up a proxy to load ads automatically |
setLocalExtra: placementID: | Set local parameters for the specified ad slot placementId: Ad position ID localExtra: extended parameters, refer to the documentation |
addAutoLoadAdPlacementIDArray: | Add ad slots that need to be loaded automatically placementIds: The ad placement id array needs to be loaded automatically |
removeAutoLoadAdPlacementIDArray: | Remove ad slots that do not need to be loaded automatically placementIds: No need to automatically load the ad placement id array |
autoLoadRewardedVideoReadyForPlacementID: | Determine whether there is an ad that can be displayed in the ad slot placementId: The ad placement ID to be queried |
showAutoLoadRewardedVideoWithPlacementID: inViewController:delegate: |
Display rewarded video ads in this ad slot placementId: The ID of the ad slot 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 in this ad slot placementId: The ID of the ad slot to be displayed scene: scene id, if no scene distinction is made, you can pass empty @"" inViewController: the viewController that displays the ad delegate: proxy object |
entryAdScenarioWithPlacementID:scenarioID: |
The corresponding ad slot enters the business scenario cache status statistics |
checkValidAdCachesWithPlacementID : |
Query all cached information of the ad slot. The first entry in the array is the ad data to be displayed. placementId: The ad placement ID to be queried Reference documentation for each element parameter |
ATAdLoadingDelegate
The following are the ad event callbacks at the ad slot level , indicating the final status of the load. For ad source level agents, please refer to the documentation
method | illustrate |
---|---|
didFinishLoadingADWithPlacementID: | The corresponding ad slot ad is loaded successfully. placementId: Ad position ID |
didFailToLoadADWithPlacementID: error: | The corresponding ad slot ad loading failed callback placementId: Ad position ID error: Ad loading failure information, see the document for details |
ATRewardedVideoDelegate
Rewarded video ad event callbacks, including display, click, and close
Callback function name | Callback function meaning |
---|---|
rewardedVideoDidRewardSuccessForPlacemenID: extra: | Incentive video advertising rewards are issued |
rewardedVideoDidStartPlayingForPlacementID: extra: | Incentive video ad playback starts, that is, incentive video display callback |
rewardedVideoDidEndPlayingForPlacementID: extra: | The rewarded video ad ends |
rewardedVideoDidFailToPlayForPlacementID: error: extra: | Rewarded video ad playback failed |
rewardedVideoDidClickForPlacementID: extra: | Rewarded video ad clicks |
rewardedVideoDidCloseForPlacementID: rewarded: extra: | Rewarded video ads off |
rewardedVideoDidDeepLinkOrJumpForPlacementID: extra: result: | Whether the rewarded video ad click jump is in the form of Deeplink. Currently, this is only returned for TopOn Adx ads. |
extra: Extended parameter reference documentation |