### Complete Taku SDK Configuration Example Source: https://help.takuad.com/docs/RgL9Yt A comprehensive example demonstrating how to configure debug logs, channels, sub-channels, custom data, excluded bundle IDs, and placement-specific data before initializing the SDK. ```dart import 'package:anythink_sdk/at_index.dart'; import '../configuration_sdk.dart'; final InitManger = InitTool(); class InitTool{ // 打开SDK的Debug log,强烈建议在测试阶段打开,方便排查问题。 setLogEnabled() async { ATInitManger .setLogEnabled( logEnabled: true, ); } // 设置渠道,可用于统计数据和进行流量分组 setChannelStr() async { ATInitManger .setChannelStr( channelStr: "test_setChannel", ); } // 设置子渠道,可用于统计数据和进行流量分组 setSubchannelStr() async { ATInitManger .setSubChannelStr( subchannelStr: "test_setSubchannelStr", ); } // 设置自定义的Map信息,可匹配后台配置的对应流量分组(App纬度)(可选配置) setCustomDataDic() async { ATInitManger.setCustomDataMap( customDataMap: { 'setCustomDataDic': 'myCustomDataDic', }, ); } // 设置排除交叉推广App列表 setExludeBundleIDArray() async { ATInitManger.setExludeBundleIDArray( exludeBundleIDList: ['test_setExludeBundleIDArray'], ); } // 设置自定义的Map信息,可匹配后台配置的对应的流量分组(Placement纬度)(可选配置) setPlacementCustomData() async { ATInitManger.setPlacementCustomData( placementIDStr: 'b5b72b21184aa8', placementCustomDataMap: {'setPlacementCustomData': 'test_setPlacementCustomData'}, ); } // 初始化Taku的SDK initTaku() async { await ATInitManger.initAnyThinkSDK( appidStr: Configuration.appidStr, appidkeyStr: Configuration.appidkeyStr); } ``` -------------------------------- ### ATSDK.start() Source: https://help.takuad.com/docs/jjZJbi TakuSDK 的启动入口,需要在 ATSDK.init 方法之后调用,启动操作会在子线程执行。仅国内 TakuSDK 需要调用,海外无需调用。 ```APIDOC ## ATSDK.start() ### Description TakuSDK 的启动入口,该 API 需要在 ATSDK.init 方法之后调用,启动操作会在子线程执行。v6.2.95 及以上版本支持,仅国内 TakuSDK 有效,海外无需调用。 ### Method start ### Parameters 无 ### Request Example ATSDK.start(); ### Notes - 需要在 ATSDK.init 之后调用 - 建议只在主进程且前台调用 - 仅国内 TakuSDK 有效,海外无需调用 ``` -------------------------------- ### Java Example: Notifying Taku SDK of Bidding Result Source: https://help.takuad.com/docs/qJT7q0 Example code demonstrating how to start a bid, load a custom interstitial ad, and notify Taku SDK of the bidding result on success or failure. ```APIDOC ## Java Example: Notifying Taku SDK of Bidding Result ### Description Example code demonstrating how to start a bid, load a custom interstitial ad, and notify Taku SDK of the bidding result on success or failure. ### Code ```java ... CustomInterstitialAd customInterstitialAd; private void startBid(Context context, final ATBiddingListener biddingListener) { customInterstitialAd = new CustomInterstitialAd(placementId); customInterstitialAd.load(placementId, new CustomAdLoadListener() { @Override public void onLoadSuccess() { //获取价格 double bidPrice = customInterstitialAd.getBidPrice(); //获取货币单位 ATAdConst.CURRENCY currency = ATAdConst.CURRENCY.USD; if (customInterstitialAd.getCurrency() == "RMB") { currency = ATAdConst.CURRENCY.RMB; } //用于标识此次竞价的唯一ID,可使用UUID或者时间戳 String token = UUID.randomUUID().toString(); //广告竞价相关事件管理类,可传null ATBiddingNotice biddingNotice = new CustomSDKBiddingNotice(customInterstitialAd); //原生广告需要返回BaseAd,其他广告形式可传null BaseAd basead = null; //通知Taku SDK竞价结果 if (biddingListener != null) { biddingListener.onC2SBiddingResultWithCache( ATBiddingResult.success(bidPrice, token, biddingNotice, currency), basead ); } } @Override public void onLoadFailed(String errorMsg) { //通知Taku SDK竞价结果 if (biddingListener != null) { biddingListener.onC2SBiddingResultWithCache(ATBiddingResult.fail(errorMsg), null); } } }); } ``` ``` -------------------------------- ### 获取广告源列表请求样例 Source: https://help.takuad.com/docs/yj3d9s Example cURL request to retrieve the advertising source list using the GET method with authentication headers. ```bash curl --location --request GET 'https://openapi.toponad.com/v3/units/list?app_ids=a63f5cced466da&placement_ids=b1ehgn65hup6v0,b640ae1464e7e9&network_ids=4779,4780&start=0&limit=200 ' \ --header 'X-Up-Key: 877f8ae9c6e9ca82c0===b5fff594c373axxx' \ --header 'X-Up-Signature: CE12B506DBCD868C2C6F09E08C139CBC' \ --header 'X-Up-Timestamp: 1626056011000' \ --header 'Content-Type: application/json' \ --data-raw '' ``` -------------------------------- ### Initialize and Prepare Native Ad Source: https://help.takuad.com/docs/oct5Mn Example of setting up the native ad view and preparing it with the native prepare info object. ```java public void showNativeAd() { ... int height = adViewWidth * 600 / 1024; height = height <= 0 ? FrameLayout.LayoutParams.WRAP_CONTENT : height; ATNativePrepareInfo nativePrepareInfo = new ATNativePrepareInfo(); View selfRenderView = LayoutInflater.from(this).inflate(R.layout.native_ad_item, null); bindSelfRenderView(this, mNativeAd.getAdMaterial(), selfRenderView, nativePrepareInfo, height) //渲染广告 mNativeAd.renderAdContainer(anyThinkNativeAdView, selfRenderView); mNativeAd.prepare(anyThinkNativeAdView, nativePrepareInfo); } ``` -------------------------------- ### collectFrameFromAdContainer Usage Example (Banner) Source: https://help.takuad.com/docs/0rPCpO3f Example implementation for Banner ads. All collection methods must be called on the main thread. ```swift func onBannerAdShow(_ bannerView: UIView, extra: [String: Any]) { MaterialMonitor.shared.collectFrameFromAdContainer( bannerView, adInfo: buildMMAdInfo(extra), timing: buildTiming(extra), options: FrameOptions(delayMs: 200), // Banner 延迟可较短 callback: self ) } ``` -------------------------------- ### + (instancetype)loadPrepareInfo: (void(^)(ATNativePrepareInfo *prepareInfo))loadPrepareInfoBlock Source: https://help.takuad.com/docs/EtpyMjsI 加载广告准备信息,通过回调块配置广告准备信息的各个UI组件,返回配置完成的广告准备信息实例。 ```APIDOC ## + (instancetype)loadPrepareInfo: (void(^)(ATNativePrepareInfo *prepareInfo))loadPrepareInfoBlock ### Description 加载广告准备信息,通过回调块配置广告准备信息的各个UI组件,返回配置完成的广告准备信息实例。 ### Method 类方法 ### Endpoint + (instancetype)loadPrepareInfo: (void(^)(ATNativePrepareInfo *prepareInfo))loadPrepareInfoBlock ### Parameters #### Parameters - **loadPrepareInfoBlock** (void(^)(ATNativePrepareInfo *prepareInfo)) - Required - 配置广告准备信息的回调块 ### Return Value - **instancetype** - 配置完成的广告准备信息实例 ### Example ```objectivec ATNativePrepareInfo *prepareInfo = [ATNativePrepareInfo loadPrepareInfo:^(ATNativePrepareInfo *prepareInfo) { // 配置UI组件 }]; ``` ``` -------------------------------- ### Get A/B Test Details Request and Response Source: https://help.takuad.com/docs/DRjqiT Use this GET request to retrieve the full configuration and status of an A/B test by its ID. ```bash url --location --request GET 'https://openapi.toponad.com/v3/abtest/5810' \ --header 'X-Up-Key: 877f8ae9c6e9ca82c0===b5fff594c373axxx' \ --header 'X-Up-Signature: CE12B506DBCD868C2C6F09E08C139CBC' \ --header 'X-Up-Timestamp: 1626056011000' \ --header 'Content-Type: application/json' \ --data-raw '' ``` ```json { "id": 5810, "name": "test_45678", "publisher_id": 0, "app_id": "a60f54770a583d", "status": 3, "start_time_type": 1, "start_time_timezone": 8, "start_time": 1627635702, "items": [ { "id": 10000066, "name": "AAA", "traffic_variation": 10, "enable": false }, { "id": 10000067, "name": "BBB", "traffic_variation": 10, "enable": false } ], "placement_ids": [ "b60f547a3d8b5d" ], "choices": [ { "placement_id": "b60f547a2904f9", "item_id": 10000066, "item_name": "AAA" } ] } ``` -------------------------------- ### 运行内置 Demo Source: https://help.takuad.com/docs/ff8JgrkV 通过命令行进入 example 目录并安装依赖,随后可运行 iOS 或 Android 版本的内置 Demo 进行排查。 ```bash cd example yarn # 安装依赖 yarn ios # 或 yarn android ``` -------------------------------- ### collectFrameFromAdPage Usage Example (Splash) Source: https://help.takuad.com/docs/0rPCpO3f Example implementation for Splash ads. The SDK automatically targets the top-most presented view controller or the key window. ```swift func splashAdDidShow() { MaterialMonitor.shared.collectFrameFromAdPage( adInfo: adInfo, timing: timing, options: FrameOptions(delayMs: 3000), // 开屏视频较长,给充足渲染时间 毫秒 callback: self ) } ``` -------------------------------- ### Install iOS SDK Dependencies Source: https://help.takuad.com/docs/AYqoOL Run this command in the directory containing your iOS Podfile to install the configured dependencies. If this is not your first time, you may need to delete podfile.lock before running. ```bash pod install --repo-update ``` -------------------------------- ### MaterialMonitor.init / get / getConfig Source: https://help.takuad.com/docs/mpsxlz0A Static methods for initializing the monitor, obtaining the singleton, checking readiness, shutting down, and reading configuration. ```APIDOC ## MaterialMonitor.init / get / getConfig ### Description Static methods for initializing the monitor, obtaining the singleton, checking readiness, shutting down, and reading configuration. ### Methods #### static void init(Application application) - **Description**: Initializes with default MaterialMonitorConfig (no upload parameters). Suitable for local-only scenarios. - **Parameters**: application (Application) - Required - The application context. #### static void init(Application application, MaterialMonitorConfig config) - **Description**: Initializes with a custom config. If config is null, uses DEFAULT equivalent empty config. - **Parameters**: application (Application) - Required - The application context. config (MaterialMonitorConfig) - Required - The configuration; null is treated as DEFAULT. #### static MaterialMonitor get() - **Description**: Returns the singleton. If not initialized or already shutdown, returns an idle placeholder instance (collect* methods are no-op and log warnings), does not throw. - **Returns**: MaterialMonitor - The singleton instance. #### static boolean isReady() - **Description**: Returns whether initialized and not yet shutdown (real instance may be lazily created on first get()). - **Returns**: boolean - true if ready, false otherwise. #### static void shutdown() - **Description**: Releases lifecycle callbacks and workers; pending upload SQLite rows are retained, can re-init later to resume uploads. #### MaterialMonitorConfig getConfig() - **Description**: Reads the configuration used at initialization; can call isUploadConfigured() to check if baseUploadUrl + appId + appKey are present. - **Returns**: MaterialMonitorConfig - The configuration. ``` -------------------------------- ### ATInterstitialAutoAd.show (with ATShowConfig) Source: https://help.takuad.com/docs/W6l8G0 展示指定广告位的插屏广告,支持传入ATShowConfig配置额外参数,如自定义参数和广告场景。 ```APIDOC ## [METHOD] ATInterstitialAutoAd.show (with ATShowConfig) ### Description 展示指定广告位的插屏广告,支持传入ATShowConfig配置额外参数,如自定义参数和广告场景。 ### Method show ### Endpoint void show(Activity activity, String placementId, ATShowConfig showConfig, ATInterstitialAutoEventListener eventListener) ### Parameters #### Path Parameters - **activity** (Activity) - Required - 展示广告的Activity - **placementId** (String) - Required - 需展示的广告位Id - **showConfig** (ATShowConfig) - Required - 展示时的额外参数,可设置showCustomExt和scenarioId - **eventListener** (ATInterstitialAutoEventListener) - Required - 插屏广告展示回调 ### Response #### Success Response 广告展示成功。 ``` -------------------------------- ### GET /v3/units Source: https://help.takuad.com/docs/yj3d9s 获取广告源详情。通过广告源ID列表查询广告源信息,返回广告源信息列表。 ```APIDOC ## [GET] /v3/units ### Description 获取广告源详情。通过广告源ID列表查询广告源信息,返回广告源信息列表。 ### Method GET ### Endpoint https://openapi.toponad.com/v3/units ### Parameters #### Query Parameters - **ids** (Array[Int]) - Required - 广告源ID列表,数量最大限制为100,最小限制为1 ### Request Example curl --location --request GET 'https://openapi.toponad.com/v3/units?ids=417018,374133' \ --header 'X-Up-Key: 877f8ae9c6e9ca82c0===b5fff594c373axxx' \ --header 'X-Up-Signature: CE12B506DBCD868C2C6F09E08C139CBC' \ --header 'X-Up-Timestamp: 1626056011000' \ --header 'Content-Type: application/json' \ --data-raw '' ### Response #### Success Response (200) - **id** (Int) - 广告源ID - **name** (String) - 广告源名称 - **network_id** (Int) - Taku广告平台账号ID - **placement_id** (String) - Taku的广告位ID - **type** (Int) - 广告源类型,枚举值:2:普通广告源,4:adx广告源,10:兜底广告源,12:客户端竞价广告源,13:服务端竞价广告源 - **mix_format** (Int) - 混合样式,枚举值:-1或和广告位format值一样:非混合类型,0:混合native类型,1:混合rewarded_video类型,2:混合banner类型,3:混合interstitial类型,4:混合splash类型 - **adsource_token** (Object) - 广告源配置参数,三方广告平台或自定义关联三方平台详见【新附录三方广告平台详细参数】规范的属性列,自定义广告平台时需满足json object格式,该属性暂不支持adx广告源(流量分组相关) - **auto_unit_sw** (Int) - 自动广告源开关,某些平台才有:1开,2关 - **nw_firm_id** (Int) - 广告平台ID #### Response Example [ { "id": 374133, "placement_id": "b6049c640e6ad1", "network_id": 4779, "name": "穿山甲_rv_3", "type": 2, "mix_format": -1, "adsource_token": { "app_id": "5343323", "personalized_template": "1", "slot_id": "4566363563" }, "auto_unit_sw": 2, "nw_firm_id": 15 }, { "id": 417018, "placement_id": "b6049c640e6ad1", "network_id": 4779, "name": "穿山甲_rv_6", "type": 2, "mix_format": -1, "adsource_token": { "app_id": "5343323", "personalized_template": "0", "slot_id": "324ewrwe" }, "auto_unit_sw": 2, "nw_firm_id": 15 } ] ``` -------------------------------- ### GET /v3/units/list Source: https://help.takuad.com/docs/yj3d9s 获取广告源列表。该接口用于查询符合条件的广告源信息,支持按应用ID、广告位ID、三方平台账号ID筛选,并支持分页。 ```APIDOC ## [GET] /v3/units/list ### Description 获取广告源列表。该接口用于查询符合条件的广告源信息,支持按应用ID、广告位ID、三方平台账号ID筛选,并支持分页。 ### Method GET ### Endpoint https://openapi.toponad.com/v3/units/list ### Parameters #### Query Parameters - **app_ids** (Array[String]) - Optional - Taku应用ID列表,数量最大限制为100 - **placement_ids** (Array[String]) - Optional - Taku广告位ID列表,数量最大限制为100 - **network_ids** (Array[Int]) - Optional - Taku三方平台账号ID列表,数量最大限制为100 - **start** (Int) - Optional - 起始偏移量,默认0 - **limit** (Int) - Optional - 获取个数,最大限制为1000,默认1000 ### Request Example curl --location --request GET 'https://openapi.toponad.com/v3/units/list?app_ids=a63f5cced466da&placement_ids=b1ehgn65hup6v0,b640ae1464e7e9&network_ids=4779,4780&start=0&limit=200' \ --header 'X-Up-Key: 877f8ae9c6e9ca82c0===b5fff594c373axxx' \ --header 'X-Up-Signature: CE12B506DBCD868C2C6F09E08C139CBC' \ --header 'X-Up-Timestamp: 1626056011000' \ --header 'Content-Type: application/json' \ --data-raw '' ### Response #### Success Response (200) - **total** (Int) - 搜索条件下的总数 - **items** (Array[Object]) - 广告源信息列表 - **items.id** (Int) - 广告源ID - **items.name** (String) - 广告源名称 - **items.app_id** (String) - Taku的应用ID - **items.placement_id** (String) - Taku的广告位ID - **items.network_id** (Int) - Taku广告平台账号ID - **items.nw_firm_id** (Int) - 广告平台ID #### Response Example { "total": 10, "items": [ { "app_id": "a6392a1c24510e", "placement_id": "b6392a1d36f73f", "network_id": 5117, "id": 2279787, "name": "ADX", "nw_firm_id": 15 }, { "app_id": "a6392a1c24510e", "placement_id": "b6392a1d59c06f", "network_id": 5117, "id": 2279797, "name": "ADX", "nw_firm_id": 15 } ] } ``` -------------------------------- ### Initialize Taku SDK and Load Ads Source: https://help.takuad.com/docs/zODjLF Demonstrates the idempotent initialization of the Taku SDK. Initialization must occur after user consent to the privacy policy and before loading any ads. ```objc #import @interface AdManager : NSObject - (BOOL)configureAdSDK; - (void)loadAd; @end @implementation AdManager /// 初始化广告 SDK /// 幂等:SDK 已初始化后重复调用会直接返回成功,因此可安全地放在每次加载广告之前 /// @return 初始化是否成功;返回 NO 时不应继续加载广告 - (BOOL)configureAdSDK { #if DEBUG // 会输出 IDFA 与设备信息,仅用于调试,禁止带入 Release 包 [ATAPI setLogEnabled:YES]; #endif NSError *error = nil; BOOL success = [[ATAPI sharedInstance] startWithAppID:@"Your AppID" appKey:@"Your AppKey" error:&error]; if (!success) { NSLog(@"[TaKu] SDK 初始化失败 domain=%@ code=%ld msg=%@", error.domain, (long)error.code, error.userInfo[@"msg"]); } return success; } /// 加载广告 /// 调用前提:用户已同意隐私政策 - (void)loadAd { // 初始化是 load 的前置步骤:先 init,成功后再 load if (![self configureAdSDK]) { return; } #if DEBUG // 三方平台集成自检,仅调试期使用,不属于初始化的必要步骤 [ATAPI integrationChecking]; #endif // 初始化成功后,再执行广告加载 // [self.bannerView loadAd:@"Your PlacementID"]; } @end ``` -------------------------------- ### Unity Splash Ad Implementation Source: https://help.takuad.com/docs/fBEROq This example demonstrates how to initialize the ATSDK, manage splash ad loading and display via a manager class, and handle ad lifecycle events within a Unity MonoBehaviour. ```csharp public class ExampleHomeScreen : MonoBehaviour, ATSDKInitListener { void Start() { #if UNITY_ANDROID ATSDKAPI.initSDK("Your Android AppId", "Your Android AppKey", this); #elif UNITY_IOS || UNITY_IPHONE ATSDKAPI.initSDK("Your iOS AppId", "Your iOS AppKey", this); #endif } void OnDestroy() { ATSplashAd.Instance.client.onAdLoadEvent -= onAdLoad; ATSplashAd.Instance.client.onAdLoadTimeoutEvent -= onAdLoadTimeout; ATSplashAd.Instance.client.onAdLoadFailureEvent -= onAdLoadFailed; ATSplashAd.Instance.client.onAdCloseEvent -= onAdClose; } //SDK初始化成功 public void initSuccess() { ATSplashAd.Instance.client.onAdLoadEvent += onAdLoad; ATSplashAd.Instance.client.onAdLoadTimeoutEvent += onAdLoadTimeout; ATSplashAd.Instance.client.onAdLoadFailureEvent += onAdLoadFailed; ATSplashAd.Instance.client.onAdCloseEvent += onAdClose; ATSplashManager.Instance.ShowAdIfReady(); } public void initFail(string msg) { Debug.Log("Developer callback SDK initFail:" + msg); } //广告加载成功,则直接显示 public void onAdLoad(object sender, ATAdEventArgs erg) { if (!erg.isTimeout) { ATSplashManager.Instance.ShowAdIfReady(); } else { //加载超时,不再调用show展示广告 } } //广告加载超时,不需继续等待广告填充,直接进入首页 public void onAdLoadTimeout(object sender, ATAdEventArgs erg) { } //广告加载失败 public void onAdLoadFailed(object sender, ATAdErrorEventArgs args) { } //广告关闭,进入首页 public void onAdClose(object sender, ATAdEventArgs erg) { } //监听APP前台事件 private void OnApplicationPause(bool pauseStatus) { if (!pauseStatus) //从后台返回前台 { ATSplashManager.Instance.ShowAdIfReady(); } } } public class ATSplashManager { #if UNITY_ANDROID private const string SPLASH_PLACEMENT_ID = "Your PlacementId"; #elif UNITY_IOS || UNITY_IPHONE private static string SPLASH_PLACEMENT_ID = "Your PlacementId"; #endif private static ATSplashManager instance = new ATSplashManager(); public static ATSplashManager Instance { get { return instance; } } public void ShowAdIfReady() { var splashAd = ATSplashAd.Instance; if (splashAd.hasSplashAdReady(SPLASH_PLACEMENT_ID)) { splashAd.showSplashAd(SPLASH_PLACEMENT_ID, new Dictionary()); } else { splashAd.loadSplashAd(SPLASH_PLACEMENT_ID, new Dictionary()); } } } ``` -------------------------------- ### GET /v3/report/device_imp_detail Source: https://help.takuad.com/docs/she-bei-zhan-shi-ming-xi-bao-biao 获取设备展示明细报表数据,返回报表数据的下载链接。 ```APIDOC ## GET /v3/report/device_imp_detail ### Description 获取设备展示明细报表数据,返回报表数据的下载链接。 ### Method GET ### Endpoint https://openapi.toponad.com/v3/report/device_imp_detail ### Parameters #### Query Parameters - **day** (Int) - Required - 开始日期,格式:YYYYmmdd,仅支持1天前的日期,例如20190501 - **app_id** (String) - Required - 开发者后台的应用ID,单选,例如xxxxx - **timezone** (Int) - Required - 时区支持,-8,8,0三个时区 ### Request Example curl --location --request GET 'https://openapi.toponad.com/v3/report/device_imp_detail?app_id=a606c22b789bc3&day=20210823&timezone=8' \ --header 'X-Up-Key: 877f8ae9c6e9ca82c0===b5fff594c373axxx' \ --header 'X-Up-Signature: CE12B506DBCD868C2C6F09E08C139CBC' \ --header 'X-Up-Timestamp: 1626056011000' \ --header 'Content-Type: application/json' ### Response #### Success Response (200) 返回报表数据的下载链接,链接格式为http://sz-topon-emr-hive.oss-cn-shenzhen.aliyuncs.com/...,文件以csv形式提供,用","作为分隔符。 #### Response Example http://sz-topon-emr-hive.oss-cn-shenzhen.aliyuncs.com/topon-openapi%2Ftopon_report_device_impression_utce8%2Fdt%3D2024-02-22%2Fpublisher_id%3D9993%2Fapp_id%3Da658d368a23640%2Fpart-00000-191f3072-eb3e-4bbc-abe0-6e52f6e3c372.c000.csv?Expires=1709028669&OSSAccessKeyId=LTAI5tKdnC9J6sdUn1SB1ju3&Signature=iFU9HlMzAzwcHD%2FwYksb355Wiok%3D #### CSV字段说明 - **request_id** (String) - 广告请求唯一ID - **sdk_time** (Int) - SDK记录的时间戳,单位毫秒 - **area** (String) - 国家两字符短码,参考iso国际标准 - **placement_id** (String) - 广告位ID - **nw_firm_id** (Int) - 广告平台的数字ID。具体参考《广告平台ID表》 - **network_pl_id** (String) - 广告平台的广告位ID信息 - **ecpm** (Decimal(18,6)) - 展示的ecpm - **channel** (String) - 渠道,由开发者通过TopOn SDK传入的渠道 - **sub_channel** (String) - 子渠道,由开发者通过TopOn SDK传入的子渠道 - **platform** (Int) - 系统平台,1:android,2:ios - **os_vn** (String) - 操作系统版本 - **idfa** (String) - iOS的设备ID - **idfv** (String) - iOS的设备ID - **gaid** (String) - Google的广告设备ID - **oaid** (String) - 安卓的设备ID - **att_status** (Int) - iOS设备的ATT授权状态:0:Not determined(未决定是否授权),1:Restricted (受限制),2:Denied(已拒绝),3:Authorize(已授权) - **user_id** (String) - 开发者的自定义用户ID - **app_custom** (String) - 应用自定义数据(Load时传入的自定义参数) - **show_custom_ext** (String) - 展示时传入的自定义参数 ``` -------------------------------- ### GET 回调URL Source: https://help.takuad.com/docs/msbnkj?search=1 Taku平台以GET方式请求开发者配置的回调URL,并拼接参数回传。开发者需处理该回调并返回状态码200、601或602。 ```APIDOC ## [GET] 回调URL ### Description Taku平台以GET方式请求开发者配置的回调URL,并拼接参数回传。开发者需处理该回调并返回状态码200、601或602。 ### Method GET ### Endpoint https://www.takuad.com/onrewardedverify?user_id={user_id}&trans_id={trans_id}&reward_amount={reward_amount}&reward_name={reward_name}&placement_id={placement_id}&extra_data={extra_data}&network_firm_id={network_firm_id}&adsource_id={adsource_id}&scenario_id={scenario_id}&sign={sign}&ilrd={ilrd} ### Parameters #### Query Parameters - **user_id** (string) - Required - 用户ID,由开发者通过Taku SDK API设置 - **extra_data** (string) - Optional - 用户业务参数,由开发者通过Taku SDK API设置 - **trans_id** (string) - Required - Taku服务端生成的trans_id,具有唯一性,强烈建议校验是否已发放激励 - **reward_name** (string) - Required - 激励名称,在开发者后台设置 - **reward_amount** (number) - Required - 激励数量,在开发者后台设置 - **placement_id** (string) - Required - Taku广告位ID - **network_firm_id** (number) - Required - Taku聚合的广告平台ID - **adsource_id** (string) - Required - Taku广告源ID - **scenario_id** (string) - Required - Taku广告场景ID,由开发者通过Taku SDK API设置 - **package_name** (string) - Optional - 开发者应用的包名或Bundle ID,由Taku SDK获取 - **platform** (number) - Optional - 系统平台,1:Android,2:iOS - **ilrd** (string) - Optional - Taku SDK回调的展示级别数据,JSON字符串,仅Taku SDK v5.7.78及以上版本支持 - **sign** (string) - Required - 签名信息,用于校验回调参数 ### Response #### Success Response (200) - **200** (number) - 成功 #### Response Example 200 ### Error Handling - **601** (number) - 签名验证失败 - **602** (number) - 其他失败 ### Notes - 回调数据可能很大,开发者应保证去除GET回调URL的长度限制,否则可能报414错误。 - Taku服务器发起回调后2秒内无响应视为超时,超时后会重试,最大重试5次。 ``` -------------------------------- ### ATSDK.init(appId, appKey) Source: https://help.takuad.com/docs/yD3E6h86 初始化 SDK,内部会建立事件分发通道(ATAdEvents),使各广告回调能分发到 JS。需在加载任何广告之前调用。 ```APIDOC ## ATSDK.init(appId, appKey) ### Description 初始化 SDK,内部会建立事件分发通道(ATAdEvents),使各广告回调能分发到 JS。需在加载任何广告之前调用。 ### Method init ### Parameters - **appId** (string) - Required - 应用 ID - **appKey** (string) - Required - 应用 Key ### Example ```ts ATSDK.init('your app id', 'your app key'); ``` ``` -------------------------------- ### GET 回调地址 Source: https://help.takuad.com/docs/nSPXupJ4 Taku通过GET请求将广告源关键信息回调给开发者后台,开发者需提供回调地址并确保服务器能接收数据。 ```APIDOC ## [GET] 回调地址 ### Description Taku通过S2S方式将广告源关键信息回调给开发者后台,开发者需提供回调地址并确保服务器能接收数据。 ### Method GET ### Endpoint https://xxx.com/xxx ### Parameters #### Query Parameters - **req_id** (string) - Required - Taku请求ID - **app_id** (string) - Required - Taku应用ID - **placement_id** (string) - Required - Taku广告位ID - **adsource_id** (string) - Required - Taku广告源ID - **adformat** (string) - Required - 广告类型,枚举说明包括:0:"Native" 1:"RewardedVideo" 2:"Banner" 3:"Interstitial" 4:"Splash" - **nw_placement_id** (string) - Required - 三方广告平台广告位ID - **nw_firm_id** (string) - Required - 三方广告平台对应的ID,支持的平台:8:腾讯广告 15:穿山甲 22:百度 28:快手 - **nw_app_id** (string) - Required - 三方广告平台应用ID - **nw_key** (string) - Required - 三方密钥 ### Response #### Success Response (200) - 回调成功后开发者服务器需要响应http状态码200,其它状态码为失败标识 #### Response Example HTTP 200 ``` -------------------------------- ### ATApkManager.startInstall(ATApk apk) Source: https://help.takuad.com/docs/duan-dian-xu-an-zhuang-huo-ji-huo-dan-chuang-ti-shi 传入loadApk()中拿到的ATApk数据,调用系统安装器进行安装。 ```APIDOC ## ATApkManager.startInstall(ATApk apk) ### Description 传入loadApk()中拿到的ATApk数据,调用系统安装器进行安装。 ### Method startInstall ### Parameters - **apk** (ATApk) - Required - 从loadApk()获取的ATApk数据。 ``` -------------------------------- ### SDK 初始化流程 Source: https://help.takuad.com/docs/yD3E6h86 在应用启动时按顺序执行日志配置、事件监听、集成检测、个性化广告设置以及 SDK 的 init 和 start 方法。 ```typescript import { ATSDK, ATAdEvents } from '@taku_anythink/react-native-sdk'; export function initSdk(personalized: boolean): void { // 1. 日志(早于 init;开发阶段开启,上线前关闭) ATSDK.setNetworkLogDebug(true); // 2. 全局事件监听(订阅各广告回调通道) ATAdEvents.init(); // 3. 集成检测(验证原生依赖是否正确接入) ATSDK.integrationChecking(); // 4. 个性化广告开关(PERSONALIZED=允许,NONPERSONALIZED=限制) ATSDK.setPersonalizedAdStatus( personalized ? ATSDK.PERSONALIZED : ATSDK.NONPERSONALIZED ); // 5. init + start ATSDK.init('your app id', 'your app key'); ATSDK.start(); console.log('SDK 初始化完成,版本:', ATSDK.getSDKVersionName()); } ```