π‘Tips: The class name can be customized, but it must be consistent with the custom ad platform class name configured in the backend. For example, if the adapter class name added in the backend is: DemoCustomSplashAdapter, then you need to create the corresponding DemoCustomSplashAdapter.m file.
Splash/
βββ DemoCustomSplashAdapter.h # Splash ad adapter header file
βββ DemoCustomSplashAdapter.m # Splash ad adapter implementation file
βββ DemoCustomSplashDelegate.h # Splash ad delegate header file
βββ DemoCustomSplashDelegate.m # Splash ad delegate implementation file
You need to inherit from DemoCustomBaseAdapter and override the relevant methods:
loadADWithArgument: method will be calledadReadySplashWithInfo: method will be calledshowSplashInViewController: method will be called| Method | Parameter Description | Purpose |
|---|---|---|
| - (void)loadADWithArgument:(ATAdMediationArgument *)argument | argument: Contains parameters from server and local configuration | Used to get server and local configuration parameters, implement custom ad loading logic |
| - (void)showSplashInViewController:(UIViewController *)viewController | viewController: The UIViewController passed when displaying the ad | Implement the logic for displaying custom ads |
| - (BOOL)adReadySplashWithInfo:(NSDictionary *)info | info: Ad information dictionary | Used to determine if the custom ad is ready before displaying |
The splash ad adapter supports the following callback methods, which are inherited from the ATBaseTrackProtocol protocol:
| Method | Description |
|---|---|
| - (void)atOnAdMetaLoadFinish:(NSDictionary *)adExtra | Callback to developer when ad data loading is completed |
| - (void)atOnAdLoadFailed:(NSError *)error adExtra:(NSDictionary *)adExtra | Callback to developer when ad loading fails |
| - (void)atOnAdShow:(NSDictionary *)adExtra | Callback to developer when ad is successfully displayed |
| - (void)atOnAdShowFailed:(NSError *)error extra:(NSDictionary *)extraDic | Callback to developer when ad display fails |
| - (void)atOnAdClick:(NSDictionary *)adExtra | Callback to developer when ad is clicked by user |
| - (void)atOnAdWillClosed:(NSDictionary *)extra | Callback to developer when ad is about to close |
| - (void)atOnAdClosed:(NSDictionary *)extra | Callback to developer when ad is closed |
| - (void)atOnAdDetailWillShow:(NSDictionary *)extra | Callback to developer when ad detail page is about to show |
| - (void)atOnAdDetailClosed:(NSDictionary *)extra | Callback to developer when ad detail page is closed |
| - (void)atOnAdDeeplinkOrJumpResult:(BOOL)success | Callback to developer with ad Deeplink jump result |
| - (void)atOnAdDidRevenue:(NSDictionary *)extraDic | Callback to developer with ad revenue |
- Import the header file
#import <AnyThinkSDK.h>- Add property:
@property (nonatomic, strong) ATAdStatusBridge * adStatusBridge;- Conform to your third-party ad SDK's splash ad callback protocol
Example:
objc Copy// Import header files #import <AnyThinkSDK/AnyThinkSDK.h> #import <Foundation/Foundation.h> @interface DemoCustomSplashDelegate : NSObject<YourSplashAdDelegate> @property (nonatomic, strong) ATAdStatusBridge * adStatusBridge; @end
- Implement your third-party SDK's protocol methods, such as ad load success, ad click, ad close, etc.
- In the third-party SDK's ad load success event, call to notify us that the ad loaded successfully
objc Copy// Ad load success - (void)splashAdDidLoad:(YourSplashAd *)splashAd { [self.adStatusBridge atOnAdMetaLoadFinish:{}]; }
- In the third-party SDK's ad load failure event, call to notify us that the ad failed to load
objc Copy// Ad load failure - (void)splashAdDidFailToLoad:(YourSplashAd *)splashAd error:(NSError *)error { [self.adStatusBridge atOnAdLoadFailed:error adExtra:nil]; }
- Refer to our SDK protocol, implement other ad events and notify us:
objc Copy// Ad load success - (void)splashAdDidLoad:(YourSplashAd *)splashAd { [self.adStatusBridge atOnAdMetaLoadFinish:{}]; } // Ad display success - (void)splashAdDidShow:(YourSplashAd *)splashAd { [self.adStatusBridge atOnAdShow:nil]; } // Ad click - (void)splashAdDidClick:(YourSplashAd *)splashAd { [self.adStatusBridge atOnAdClick:nil]; } // Ad close - (void)splashAdDidClose:(YourSplashAd *)splashAd { [self.adStatusBridge atOnAdClosed:nil]; }
- Inherit from DemoCustomBaseAdapter
- Import the header file
#import <AnyThinkSDK.h>- Conform to the
ATBaseSplashAdapterProtocolprotocol
- Add the following properties:
objc Copy@interface DemoCustomSplashAdapter() @property (nonatomic, strong) DemoCustomSplashDelegate *splashDelegate; @property (nonatomic, strong) YourSplashAd *splashAd; @end
- Initialize the
splashDelegatepropertyobjc Copy#pragma mark - lazy - (DemoCustomSplashDelegate *)splashDelegate{ if (_splashDelegate == nil) { _splashDelegate = [[DemoCustomSplashDelegate alloc] init]; _splashDelegate.adStatusBridge = self.adStatusBridge; } return _splashDelegate; }
- Implement the ad loading method:
objc Copy#pragma mark - Ad load - (void)loadADWithArgument:(ATAdMediationArgument *)argument { self.splashAd = [[YourSplashAd alloc] init]; self.splashAd.delegate = self.splashDelegate; [self.splashAd loadAdWithSlotId:argument.serverContentDic[@"slot_id"]]; }
- Implement the ad display method:
objc Copy#pragma mark - Ad show - (void)showSplashInViewController:(UIViewController *)viewController { [self.splashAd showInViewController:viewController]; }
- Implement the ad ready status check method:
objc Copy#pragma mark - Ad ready - (BOOL)adReadySplashWithInfo:(NSDictionary *)info { return self.splashAd.isAdValid; }