This document is based on the DemoCustomBaseAdapter example code in the Demo, providing detailed instructions on how to create a custom base adapter. The main function of this adapter is to initialize third-party ad platform SDKs and return their version information.
π‘ Tips
- Class names can be customized; base adapter and initialization adapter class names do not need to be added to the backend
- It is recommended to place the base adapter and initialization adapter in the same module for easier management
- The initialization adapter is responsible for SDK initialization, while the base adapter is responsible for specifying the initialization adapter class name
You need to inherit from ATBaseMediationAdapter and ATBaseInitAdapter and override the relevant methods:
| Method | Parameter Description | Purpose |
|---|---|---|
| - (void)initWithInitArgument:(ATAdInitArgument *)adInitArgument | adInitArgument: Contains initialization parameters sent from the server | Used to initialize third-party ad platform SDK and set related parameters |
| - (nullable NSString *)sdkVersion | ----- | Returns the version number of the ad platform SDK |
| - (nullable NSString *)adapterVersion | ----- | Returns the adapter version number |
| Method | Parameter Description | Purpose |
|---|---|---|
| - (Class)initializeClassName | ----- | Returns the class name of the initialization adapter, used to specify the initialization adapter |
βββ Base/ # Base adapter module
β βββ DemoCustomAdapterCommonHeader.h # Used to declare common header files
β βββ DemoCustomBaseAdapter.h # Base adapter header file
β βββ DemoCustomBaseAdapter.m # Base adapter implementation, defines the initialization adapter class name
β βββ DemoCustomInitAdapter.h # Initialization adapter header file
β βββ DemoCustomInitAdapter.m # Initialization adapter implementation
- Import header file
#import <AnyThinkSDK.h>- Inherit from
ATBaseInitAdapterExample:
objc Copy#import <Foundation/Foundation.h> #import "DemoCustomAdapterCommonHeader.h" @interface DemoCustomInitAdapter : ATBaseInitAdapter @end
Implement the following methods:
objc Copy/// Init Ad SDK /// - Parameter adInitArgument: server info - (void)initWithInitArgument:(ATAdInitArgument *)adInitArgument{ // Get backend configuration information from the adInitArgument object, e.g., adInitArgument.serverContentDic[@"appId"] // After obtaining the relevant information, call the ad platform SDK's initialization method. You can configure the ad platform SDK as needed, such as privacy settings for overseas platforms (e.g., CCPA, COPPA, GDPR). // If the ad platform SDK initialization has a return value, use [self notificationNetworkInitSuccess]; to notify us of successful initialization; // If third-party initialization fails, use [self notificationNetworkInitFail:error]; to notify us of initialization failure. // If the ad platform SDK initialization has no success or failure callback, you can directly notify us of successful initialization using: [self notificationNetworkInitSuccess]; } /// Returns the version number of the ad platform SDK - (nullable NSString *)sdkVersion { // Example return [YourAdSDK getVersion]; } /// Returns the adapter version number - (nullable NSString *)adapterVersion { return [YourAdapter getVersion]; }
- Import header file
#import <AnyThinkSDK.h>- Inherit from
ATBaseMediationAdapterExample:
objc Copy@interface DemoCustomBaseAdapter : ATBaseMediationAdapter @end
Implement the following method:
objc Copy#pragma mark - adapter init class name define - (Class)initializeClassName { // Return the initialization adapter class created in Step 1 of this document return [DemoCustomInitAdapter class]; }
4.1 GDPR
Get the data consent level you set through TaKu SDK's
-[ATAPI setDataConsentSet:consentString:]methodobjc Copy//typedef NS_ENUM(NSInteger, ATDataConsentSet) { // /* // This is the default value used when you haven't set one; in this case, if the user is in a GDPR region, SDK initialization will fail, // and subsequent ad requests will also fail. This type cannot be set using the setDataConsentSet method // */ // ATDataConsentSetUnknown = 0, // /* // This level indicates that the user consents to the SDK collecting and using their personal data to provide more relevant and suitable ads. // */ // ATDataConsentSetPersonalized = 1, // /* // If the data protection level is set to this value, the SDK will not collect user personal data, as the provided ads may not match the user's situation. // Additionally, in this case, some data that doesn't involve user privacy may still be collected. // */ // ATDataConsentSetNonpersonalized = 2 //}; // Import header file `#import <AnyThinkSDK.h>` // Get data consent level [ATAPI sharedInstance].dataConsentSet4.2 COPPA
Get the user age you set through Taku SDK
After the developer calls[ATSDKGlobalSetting sharedManager].customData = @{kATCustomDataAgeKey:@"13",......};
to set the age, you can get the user age set by the developer through
[[ATSDKGlobalSetting sharedManager].customData valueForKey:kATCustomDataAgeKey]4.3 Personalized Ads
Get the personalized ad state set by the developer through Taku SDK
After the developer calls
[[ATAPI sharedInstance] setPersonalizedAdState:ATPersonalizedAdStateType]
to set the personalized ad state, you can get the personalized ad state set by the developer through
[ATAPI sharedInstance].getPersonalizedAdState