---
code: ios_sdk_thirdparty
name: "三方数据"
wikiToken: NUm1wa8Qii1F41kIKKic4lTDn2c
parentWikiToken: T7Ocw5qr7is1Z5k0P6VcZVSKnDd
updateTime: 1745309660000
sourceUrl: https://docs-v2.thinkingdata.cn/?version=v5.0&lan=zh-CN&code=ios_sdk_thirdparty
---
# 三方数据

**最新版本: **v0.3.5

**更新时间:** 2025-02-10

**资源下载: **源代码 Framework 下载

使用cocopoads方式来集成：

```
pod 'TAThirdParty'
```

 ThinkingSDK 从 v2.8.0 开始支持三方数据接入功能，以下是同步多个平台数据的示例代码:

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppsFlyer | TDThirdPartyTypeAdjust | TDThirdPartyTypeTradPlus | TDThirdPartyTypeTracking | TDThirdPartyTypeTopOn | TDThirdPartyTypeBranch | TDThirdPartyTypeIronSource];
```

<!-- unsupported block: 34 -->

如果需要增加额外参数，可以使用`enableThirdPartySharing:customMap`，该API不支持位运算

### 一、Appsflyer

在AppsFlyer SDK调用start方法之前调用API 

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppsFlyer];
```

注册创角色之后(可选) 

```
[TDAnalytics login:@"account_id"];
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppsFlyer properties:@{@"ta_data11":@"ta_value11"}];
```

每次调用了TE的`login`方法或者`setDistinctId`方法，您需要同步调用 `enableThirdPartySharing`更新用户标识。

注意:由于AppFlyer的setAdditionalData每次调用，会覆盖设置的用户标识。您可以通过我们提供的`enableThirdPartySharing`方法设置参数:

```
NSDictionary *dic = @{@"af_test_key1": @"test1",@"af_test_key2": @"test2"};
[AppsFlyerLib.shared setAdditionalData:dic];
```

因为setAdditionalData调用多次，会覆盖之前的参数，可以将参数传递给TE，SDK内部会将参数进行拼接合并

```
NSDictionary *dic = @{@"af_test_key1": @"test1",@"af_test_key2": @"test2"};
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppsFlyer properties:dic];
```

### 二、Adjust

在Adjust SDK初始化之前调用 

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAdjust];
```

注册创角色之后(可选) 

```
[TDAnalytics login:@"account_id"];
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAdjust];
```

### 三、Branch

在Branch SDK初始化之前调用 

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeBranch];
```

注册创角色之后(可选) 

```
[TDAnalytics login:@"account_id"];
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeBranch];
```

### 四、TopOn

在ATSDK初始化*之前调用:*

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeTopOn];
```

多次调用TE的`login`或者`setDistinctId`，需要再次调用enableThirdPartySharing同步数据。

注意:由于TopOn的`setCustomData`每次调用，会覆盖设置的用户标识。您可以通过我们提供的`enableThirdPartySharing`方法设置参数:

```
NSDictionary *dic = @{@"test_key1": @"test1", @"test_key2": @"test2"};
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeTopOn properties:dic];
```

### 五、Tradplus

在TradPlusSdk初始化之前调用

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeTradPlus];
```

### 六、IronSource

在IronSourceSdk初始化之后调用

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeIronSource];
```

### 七、AppLovin

- 展示级别
在AppLovinSdk初始化之后调用

```
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppLovin];
```

- 用户级别
如果要实现变现数据获取，您需要实现 `-[MAAdRevenueDelegate didPayRevenueForAd:]`，在该方法中获取变现数据并且通过 SDK 的`enableThirdPartySharing`进行数据上报，示例代码如下：

```
- (**void**)didPayRevenueForAd:(MAAd *)ad {
    //获取 Ad 数据
    NSDictionary *adInfo = @{
        @"ad_id": ad.adUnitIdentifier,
        @"revenue": @(ad.revenue),
        @"countryCode": [[[ALSdk shared] configuration] countryCode],
        @"networkName": ad.networkName,
        @"adUnitId": ad.adUnitIdentifier,
        @"adFormat": ad.format,
        @"placement": ad.placement
    };
    [TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppLovin];
    [TDAnalytics track:@"appLovin_sdk_ad_revenue" properties:adInfo];
}
```
