Manual loading mode can satisfy developers who need flexible access.
ATAdManager: Management class for rewarded video ads
Method | Description |
---|---|
sharedManager | Get 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];
}
Method | Description |
---|---|
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
}
}
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.
Method | Description |
---|---|
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
}
ATAdLoadingDelegate method
Method | Description |
---|---|
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
Method | Callback 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
Method | 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 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);
}
Method | Type | Description |
---|---|---|
kATAdLoadingExtraUserIDKey | NSString | (optional) used for server incentives, user unique ID |
kATAdLoadingExtraMediaExtraKey | NSString | (optional) used for server incentives, user-defined data |
kATAdLoadingExtraRewardNameKey | NSString | (optional) used for server incentives, reward name |
kATAdLoadingExtraRewardAmountKey | NSNumber | (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];
Method | Description |
---|---|
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);
#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.