Menu

Custom Splash Ad Adapter

πŸ’‘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.

Copy
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

2. Required Methods to Override

You need to inherit from DemoCustomBaseAdapter and override the relevant methods:

  • When developers call the ad loading API, the custom Adapter's loadADWithArgument: method will be called
  • When developers call the ad ready status check API, the custom Adapter's adReadySplashWithInfo: method will be called
  • When developers call the ad display API, the custom Adapter's showSplashInViewController: 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

3. Callback Methods Description

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

4. Implementation Steps

4.1 Implement DemoCustomSplashDelegate.h

  1. Import the header file #import <AnyThinkSDK.h>
  2. Add property: @property (nonatomic, strong) ATAdStatusBridge * adStatusBridge;
  3. 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

4.2 Implement DemoCustomSplashDelegate.m

  1. Implement your third-party SDK's protocol methods, such as ad load success, ad click, ad close, etc.
  2. 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:{}];
}
  1. 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];
}
  1. 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];
}

4.3 Implement DemoCustomSplashAdapter.h

  1. Inherit from DemoCustomBaseAdapter
  2. Import the header file #import <AnyThinkSDK.h>
  3. Conform to the ATBaseSplashAdapterProtocol protocol

4.4 Implement DemoCustomSplashAdapter.m

  1. Add the following properties:
objc Copy
@interface DemoCustomSplashAdapter()

@property (nonatomic, strong) DemoCustomSplashDelegate *splashDelegate;
@property (nonatomic, strong) YourSplashAd *splashAd;

@end
  1. Initialize the splashDelegate property
objc Copy
#pragma mark - lazy
- (DemoCustomSplashDelegate *)splashDelegate{
    if (_splashDelegate == nil) {
        _splashDelegate = [[DemoCustomSplashDelegate alloc] init];
        _splashDelegate.adStatusBridge = self.adStatusBridge;
    }
    return _splashDelegate;
}
  1. 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"]];
}
  1. Implement the ad display method:
objc Copy
#pragma mark - Ad show
- (void)showSplashInViewController:(UIViewController *)viewController {
    [self.splashAd showInViewController:viewController];
}
  1. Implement the ad ready status check method:
objc Copy
#pragma mark - Ad ready
- (BOOL)adReadySplashWithInfo:(NSDictionary *)info {
    return self.splashAd.isAdValid;
}

Last modified: 2025-10-10Powered by