C2S (Client-to-Server) bidding is a client-side bidding mechanism that allows ad adapters to perform real-time bidding on the client side and return bidding results to the ad platform. This document provides detailed instructions on how to implement C2S bidding functionality in custom ad adapters.
- SDK version >= 6.4.94
- Third-party ad SDK must support price retrieval
- Custom Adapter integration must be completed by referring to the documentation
In the Delegate class corresponding to the custom Adapter, retrieve the price returned by the third-party ad SDK, assemble the price into a dictionary object using our specified Key, and pass the price to the Taku SDK along with the ad load success event. You can use the following Keys to assemble the price dictionary:
Key Value Type Description ATAdSendC2SCurrencyTypeKey NSInteger Currency enumeration value
USD=1
CNY Yuan=2
CNY Cents=3ATAdSendC2SBidPriceKey NSString Price Example:
objc Copy// Get price from third-party ad SDK NSInteger ecpm = [splashAd ecpm]; // Dictionary to store C2S information NSMutableDictionary *infoDic = [NSMutableDictionary dictionary]; // Convert to string, choose appropriate precision based on situation NSString *priceStr = [NSString stringWithFormat:@"%ld",ecpm]; NSString *logOriginalString = [NSString stringWithFormat:@"C2S Original priceStr :%@",priceStr]; // Parameter validation if ([priceStr doubleValue] < 0) { priceStr = @"0"; } // Pass price string [infoDic AT_setDictValue:priceStr key:ATAdSendC2SBidPriceKey]; // Pass currency type based on third-party ad SDK's price unit [infoDic AT_setDictValue:@(ATBiddingCurrencyTypeCNYCents) key:ATAdSendC2SCurrencyTypeKey]; // infoDic is now the final required dictionaryYou can pass the dictionary containing price information through the following methods based on different ad types in custom Adapters:
Method Name Parameter Description Method Description - (void)atOnSplashAdLoadedExtra:(NSDictionary * _Nullable)adExtra Extra information dictionary Splash ad loaded successfully, can include C2S price information - (void)atOnInterstitialAdLoadedExtra:(NSDictionary * _Nullable)adExtra Extra information dictionary Interstitial ad loaded successfully, can include C2S price information - (void)atOnBannerAdLoadedWithView:(UIView * _Nullable)bannerView adExtra:(NSDictionary * _Nullable)adExtra 1. Third-party SDK banner ad object
2. Extra information dictionaryBanner ad loaded successfully, can include C2S price information - (void)atOnNativeAdLoadedArray:(NSArray <ATCustomNetworkNativeAd >)nativeObjectArray adExtra:(NSDictionary *_Nullable)adExtra 1. Assembled native ad object array
2. Extra information dictionaryNative ad loaded successfully, can include C2S price information - (void)atOnRewardedAdLoadedExtra:(NSDictionary * _Nullable)adExtra; Extra information dictionary Rewarded video ad loaded successfully, can include C2S price information Example with splash ad:
objc Copy#import <AnyThinkSDK/AnyThinkSDK.h> @implementation DemoCustomSplashDelegate /** * Third-party SDK splash ad ready callback * Callback timing explanation: In this example, the third-party ad SDK callback can both get the price and confirm ad readiness */ - (void)msSplashAdReadySuccess:(MSSplashAd *)splashAd { // Get price from third-party ad SDK NSInteger ecpm = [splashAd ecpm]; NSMutableDictionary *infoDic = [NSMutableDictionary dictionary]; NSString *priceStr = [NSString stringWithFormat:@"%ld",ecpm]; NSString *logOriginalString = [NSString stringWithFormat:@"C2S Original priceStr :%@",priceStr]; NSLog(@"Retrieved ad price:%@",logOriginalString); if ([priceStr doubleValue] < 0) { priceStr = @"0"; } [infoDic AT_setDictValue:priceStr key:ATAdSendC2SBidPriceKey]; [infoDic AT_setDictValue:@(ATBiddingCurrencyTypeCNYCents) key:ATAdSendC2SCurrencyTypeKey]; NSString *logString = [NSString stringWithFormat:@"[Network:C2S]::%@",infoDic]; NSLog(@"Retrieved C2S information:%@",logString); // Pass price to mediation SDK [self.adStatusBridge atOnSplashAdLoadedExtra:extraDic]; } ......Tips
- If the third-party ad SDK's ad load success callback occurs before its price return callback, you can notify us in the price return callback
- If the third-party ad SDK's ad load success callback occurs after its price return, you can first save the price using an instance variable, then notify us after the ad load success callback
You need to implement the following method in the custom Adapter class for each ad type:
Method Name Parameter Description - (void)didReceiveBidResult:(ATBidWinLossResult *)result ATBidWinLossResult *result Bidding result callback sent by mediation SDK ATBidWinLossResult Class Description
The
ATBidWinLossResultclass is used to represent bidding result information, containing data related to successful or failed bidding.ATBidWinLossResultType
Enum Value Numeric Value Description ATBidWinLossResultTypeWin0 Bidding successful ATBidWinLossResultTypeLoss1 Bidding failed ATBidWinLossResult Property Description
Property Name Type Description Notes bidResultTypeATBidWinLossResultTypeBidding result type Indicates whether this bidding was successful or failed lossReasonTypeATBiddingLossTypeFailure reason type When bidding fails, specifies the specific reason for failure winPriceNSString *Winning price The actual transaction price when bidding is successful, currency consistent with ATAdSendC2SCurrencyTypeKey secondPriceNSString *Second price The second highest bid in the bidding process, currency consistent with ATAdSendC2SCurrencyTypeKey userInfoDicNSDictionary *User information dictionary Extended information Usage Example
Example with splash ad:
objc Copy@implementation DemoCustomSplashAdapter #pragma mark - Bidding result callback sent by mediation SDK - (void)didReceiveBidResult:(ATBidWinLossResult *)result { if (result.bidResultType == ATBidWinLossResultTypeWin) { // Won this bid, call third-party SDK code to inform them, extract required information from result }else { // Lost this bid, call third-party SDK code to inform them, extract required information from result } } ......