ATAdManager's loadADWithPlacementID: method for ad loading.Regarding custom callback parameters for auto-load Rewarded Video ads, you need to pay attention to the following callback method:
- (void)rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
/* Set extra, custom parameters that will be passed back in the delegate's Extra. Can be used for custom rule matching for this ad placement.
When the server-side Rewarded Video callback is enabled, this value is set and then passed back to the developer when the reward is distributed.
Special Note: If using a third-party Rewarded Video server-side callback service, due to the SDK's internal ad caching feature, the passed extended parameters may not be able to be changed in real time. Therefore, if you have such a
requirement, please use our Rewarded Video server-side callback service and set the corresponding extended parameters in the display API (requires using the regular Rewarded Video loading method).
*/
[[ATRewardedVideoAutoAdManager sharedInstance] setLocalExtra:
@{kATAdLoadingExtraUserIDKey:@"test_user_id"} placementID:@"your rv placementID"];
}
// Import header file
#import <AnyThinkRewardedVideo/AnyThinkRewardedVideo.h>
/// Set auto-load Rewarded Video ad
/// - Parameter placementID: Ad Placement ID
- (void)loadRewardedVideoADWithPlacementID:(NSString *)placementID {
[ATRewardedVideoAutoAdManager sharedInstance].delegate = self;
// Set extra, custom parameters that will be passed back in the delegate's Extra. Can be used for custom rule matching for this ad placement.
// When the server-side Rewarded Video callback is enabled, this value will be passed back to the developer when the reward is distributed.
[[ATRewardedVideoAutoAdManager sharedInstance] setLocalExtra:
@{kATAdLoadingExtraUserIDKey:@"test_user_id"} placementID:placementID];
[[ATRewardedVideoAutoAdManager sharedInstance] addAutoLoadAdPlacementIDArray:@[placementID]];
}
- Please avoid displaying ads in the (didFinishLoadingADWithPlacementID:) callback, as this will create a load-display loop.
- Before displaying, you need to first check that the current app is in the foreground.
/// Display Ad
/// - Parameters:
/// - placementID: Ad Placement ID
- (void)showRewardedVideoADWithPlacementID:(NSString *)placementID {
// Before displaying, check whether the ad is ready
BOOL isReady = [[ATRewardedVideoAutoAdManager sharedInstance] autoLoadRewardedVideoReadyForPlacementID:placementID];
if (isReady) {
[[ATRewardedVideoAutoAdManager sharedInstance] showAutoLoadRewardedVideoWithPlacementID:placementID inViewController:self delegate:self];
}
}
| Class Name / File Name | Introduction |
|---|---|
| ATAdManager | The base ad operation class, including ad loading, filtering ads, scenario statistics, and other features. |
| ATRewardedVideoAutoAdManager | The auto-load Rewarded Video ad management class, providing features for enabling auto load, removing auto load, setting local parameters, checking readiness status, displaying ads, and scenario statistics. |
| ATAdLoadingDelegate | The base delegate callback declaration for ads, including ad placement-level and Ad Source-level load success or failure callbacks, and bid completion and bid failure callbacks for bidding Ad Sources. |
| ATRewardedVideoDelegate | Delegate callbacks for the Rewarded Video ad type, including impression, click, and close, etc. |
| ATSDKGlobalSetting | General settings class, providing features such as clearing in-memory ad caches, custom traffic group settings, test mode, configuring third-party ad SDK information, etc. It also declares some common properties. |