Integration
Pod Integration
//神策三方数据 SDK 提供了针对三方数据的 subspec,请根据自身需要安装相应的 subspec pod 'SensorsThirdParty/XXX' 或者 pod 'SensorsThirdParty', :subspecs => ['xxx'] //对接 AppsFlyer //如果集成的 AppsFlyerFramework 为静态库,请按照下面方式集成 SensorsThirdParty pod 'SensorsThirdParty/AppsFlyer' 或者 pod 'SensorsThirdParty', :subspecs => ['AppsFlyer'] //或者集成的 AppsFlyerFramework 为动态库,请按照下面方式继承 SensorsThirdParty pod 'SensorsThirdParty/AppsFlyerDynamic' 或者 pod 'SensorsThirdParty', :subspecs => ['AppsFlyerDynamic'] //对接 Adjust pod 'SensorsThirdParty/Adjust' 或者 pod 'SensorsThirdParty', :subspecs => ['Adjust']
Source Code Integration
Copy the source code from the Github repository: https://github.com/sensorsdata/SensorsThirdParty and copy all the files under iOS/SensorsThirdParty/SensorsThirdParty/Source to your project.
Usage
API Introduction
SensorsThirdParty provides the interface shareData:toThirdParty: to achieve third-party data integration, the specific parameter definitions are as follows:
Parameter | Type | Description |
---|---|---|
data | NSDictionary | The content of the shared data to the third party |
thirdParty | SAThirdPartyName | An enumeration type, such as SAThirdPartyNameAppsFlyer which represents AppsFlyer |
Integration with AppsFlyer
Call the ShareData method before calling the start method in the AppsFlyer SDK. Example of usage:
// 导入 AppsFlyer SDK #import <AppsFlyerLib/AppsFlyerLib.h> // 导入神策埋点 SDK #import <SensorsAnalyticsSDK/SensorsAnalyticsSDK.h> // 导入神策三方数据 SDK #import <SensorsThirdParty/SensorsThirdParty.h> // 初始化 AppsFlyer SDK [[AppsFlyerLib shared] setAppsFlyerDevKey:@"AppsFlyer 中创建的应用的 dev key"]; [[AppsFlyerLib shared] setAppleAppID:@"AppStore 中对应的 app id"]; ... // 初始化神策 SDK SAConfigOptions *saOptions = [[SAConfigOptions alloc] initWithServerURL:@"神策埋点数据接收地址" launchOptions:launchOptions]; ... [SensorsAnalyticsSDK startWithConfigOptions:saOptions]; // 在调用 AppsFlyer SDK start 方法前调用 shareData 方法 [SensorsThirdParty shareData:"需要共享的数据" toThirdParty:SAThirdPartyNameAppsFlyer]; // 调用 AppsFlyer SDK 的 start,请注意按照 AppsFlyer SDK 的集成要求来调用 start 方法,这里只是举例来说明 share 方法需要在 start 方法前调用 [AppsFlyerLib.shared start];
- The version number of the AppsFlyer SDK must be >= 6.9.2.
- The customData interface of the AppsFlyer SDK will overwrite data each time it is called. Please do not use the customData interface of the AppsFlyer SDK. Instead, use our provided shareData interface to avoid overwriting issues with the Sensors Analytics identification. The shareData interface provided by Sensors Analytics will merge the shared data each time it is called.
- The shareData interface needs to be called before calling the start method in the AppsFlyer SDK to ensure that the activation event carries the shared data and does not affect attribution analysis.
- If you want to include shared data in the in-app events of AppsFlyer, please call the shareData method before calling the logEvent method in the AppsFlyer SDK.
Integration with Adjust
Call the shareData method before initializing the Adjust SDK.
// 导入 Adjust SDK #import <Adjust/Adjust.h> // 导入神策埋点 SDK #import <SensorsAnalyticsSDK/SensorsAnalyticsSDK.h> // 导入神策三方数据 SDK #import <SensorsThirdParty/SensorsThirdParty.h> // 初始化神策 SDK SAConfigOptions *saOptions = [[SAConfigOptions alloc] initWithServerURL:@"神策埋点数据接收地址" launchOptions:launchOptions]; ... [SensorsAnalyticsSDK startWithConfigOptions:saOptions]; // 在调用 Adjust SDK 初始化之前调用 shareData 方法 [SensorsThirdParty shareData:"需要共享的数据" toThirdParty:SAThirdPartyNameAdjust]; // 初始化 Adjust SDK ADJConfig *config = [ADJConfig configWithAppToken:@"your Adjust app token" environment:ADJEnvironmentSandbox allowSuppressLogLevel:YES]; ... [Adjust appDidLaunch:config];
- The version number of the Adjust SDK must be >= 4.33.4.
- The version number of SensorsThirdParty must be >= 0.0.3.
- The shareData interface needs to be called before initializing the Adjust SDK to ensure that the Adjust activation event carries the shared data and does not affect attribution analysis.