Appearance
Adjust
概述
宝船 SDK 已经引入 Adjust,并做了相应封装。通过接入宝船 SDK,你可以轻松实现 Adjust 的功能,在你的应用中跟踪归因、事件及更多数据。
应用接入
1.在应用的 AppDelegate类中添加如下方法:
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.appToken = @"";//宝船平台申请adjust的appToken
config.environment = @"sandbox";
config.suppressLogLevel = YES;//是否禁用所有日志记录。设为 true 可禁用日志记录;设为 false 可启用日志记录
config.logLevel = 1;
config.externalDeviceId = @"yourExternalDeviceId";//设置外部设备标识符
config.defaultTracker = @"{Token}";//设置默认链接识别码
config.isCostDataInAttributionEnabled = YES;//启用成本数据发送。
config.isSendingInBackgroundEnabled = YES;//启用后台发送
[BrickManager initWithBrickAdjustWith:config];
配置
1.实例化 config 对象
- appToken (NSString):您的 Adjust 应用识别码
- environment (NSString):SDK 运行的环境。传送 sandbox,可在 sandbox 模式下运行 SDK,方便进行测试;传送 production,可在生产模式下运行 SDK,方便发布
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.appToken = @"";//宝船平台申请adjust的appToken
config.environment = @"sandbox";
2.设置日志级别
config.logLevel = 1;
3.设置外部设备标识符
config.externalDeviceId = @"yourExternalDeviceId";//设置外部设备标识符
4.设置默认链接识别码
config.defaultTracker = @"{Token}"
5.启用成本数据发送
config.isCostDataInAttributionEnabled = YES;
动态配置
1.激活离线模式
[BrickManager brickAdjustSwitchToOfflineMode];
2.禁用离线模式
[BrickManager brickAdjustSwitchBackToOnlineMode];
3.设置推送标签
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)pushToken {
[BrickManager brickAdjustSetPushToken:pushToken];
}
4.禁用 SDK
[BrickManager brickAdjustDisable];
5.启用 SDK
[BrickManager brickAdjustEnable];
6.查看启用状态
[BrickManager brickAdjustIsEnabledWithCompletionHandler:^(BOOL isEnabled) {
// Your completion handler
}];
记录广告收入信息
示例
BrickADJAdRevenue *adRevenue = [[BrickADJAdRevenue alloc] init];
adRevenue.source = @"source";
adRevenue.amount = 1;
adRevenue.currency = @"CNY"; adRevenue.adImpressionsCount = 10; adRevenue.adRevenueNetwork = @"network1";
adRevenue.adRevenueUnit = @"unit1"; adRevenue.callbackParameters = @{@"key1":@"value1"}; adRevenue.partnerParameters = @{@"key2":@"value2"};
adRevenue.adRevenuePlacement = @"banner";
[BrickManager brickAdjustTrackAdRevenue:adRevenue];
1.发送广告收入
+ (void)brickAdjustTrackAdRevenue:(nonnull BrickADJAdRevenue *)adRevenue;
2.记录广告收入额
BrickADJAdRevenue *adRevenue = [[BrickADJAdRevenue alloc] init];
adRevenue.amount = 1;
adRevenue.currency = @"CNY";
3.广告展示
adRevenue.adImpressionsCount = 10;
4.广告收入渠道
adRevenue.adRevenueNetwork = @"network1";
5.广告收入单元
adRevenue.adRevenueUnit = @"unit1";
6.广告收入位置
adRevenue.adRevenuePlacement = @"banner";
7.添加回传参数
adRevenue.callbackParameters = @{@"key1":@"value1"};
8.添加合作伙伴参数
adRevenue.partnerParameters = @{@"key2":@"value2"};
设置 App Tracking Transparency
示例
[BrickManager brickAdjustRequestAppTrackingAuthorizationWithCompletionHandler:^(NSUInteger status) {
switch (status) {
case 0:
// ATTrackingManagerAuthorizationStatusNotDetermined case
break;
case 1:
// ATTrackingManagerAuthorizationStatusRestricted case
break;
case 2:
// ATTrackingManagerAuthorizationStatusDenied case
break;
case 3:
// ATTrackingManagerAuthorizationStatusAuthorized case
break;
}
}];
1.获取当前授权状态
int authorizationStatus = [BrickManager brickAdjustAppTrackingAuthorizationStatus];
2.自定义弹窗时机
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.attConsentWaitingInterval = 30;
获取归因信息
[BrickManager setBrickAdjustDelegate:self];
#pragma mark - BrickAdjustDelegate
- (void)brickAdjustAttributionChanged:(NSDictionary *)attribution {
NSLog(@"attribution:%@",attribution);
}
1.获取当前归因信息
[BrickManager brickAdjustAttributionWithCompletionHandler:^(NSDictionary * _Nullable result) {
// add your completion handler
}];
发送回传信息
1.会话回传
- (void)brickAdjustSessionTrackingSucceeded:(nullable NSDictionary *)sessionSuccessResponse {
NSLog(@"sessionSuccessResponse:%@",sessionSuccessResponse);
}
- (void)brickAdjustSessionTrackingFailed:(NSDictionary *)sessionFailureResponse {
NSLog(@"sessionFailureResponse:%@",sessionFailureResponse);
}
2.事件回传
- (void)brickAdjustEventTrackingSucceeded:(NSDictionary *)eventSuccessResponse {
NSLog(@"eventSuccessResponse:%@",eventSuccessResponse);
}
- (void)brickAdjustEventTrackingFailed:(NSDictionary *)eventFailureResponse {
NSLog(@"eventFailureResponse:%@",eventFailureResponse);
}
获取设备信息
1.Adjust 设备标识符
[BrickManager brickAdjustAdidWithCompletionHandler:^(NSString * _Nullable adid) {
// add your completion handler
}];
2.广告主 ID
[BrickManager brickAdjustIdfaWithCompletionHandler:^(NSString * _Nullable idfa) {
// add your completion handler
}];
3.供应商 ID
[BrickManager brickAdjustIdfvWithCompletionHandler:^(NSString * _Nullable idfa) {
// add your completion handler
}];
4.Adjust SDK 版本 getter
[BrickManager brickAdjustSdkVersionWithCompletionHandler:^(NSString * _Nullable sdkVersion) {
// add your completion handler
}];
发送事件信息
示例:
BrickADJEvent *event = [[BrickADJEvent alloc] init];
event.eventToken = @"abc123";
event.amount = 0.01;
event.currency = @"CNY";
event.deduplicationId = @"deduplication_id"; event.callbackParameters = @{@"key1":@"value1"};
event.callbackParameters = @{@"key2":@"value2"};
event.partnerParameters = @{@"key3":@"value3"};
event.callbackId = @"Your-Custom-ID";
[BrickManager brickAdjustTrackEvent:event];
1.发送事件
BrickADJEvent *event = [[BrickADJEvent alloc] init];
event.eventToken = @"abc123";
[BrickManager brickAdjustTrackEvent:event];
2.记录事件收入
event.amount = 0.01;
event.currency = @"CNY";
3.收入事件去重
event.deduplicationId = @"deduplication_id";
4.设置去重 ID 限制
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.eventDeduplicationIdsMaxSize = 20;
5.添加回传参数
event.callbackParameters = @{@"key1":@"value1"};
6.添加合作伙伴参数
event.partnerParameters = @{@"key3":@"value3"};
7.添加回传标识符
event.callbackId = @"Your-Custom-ID";
深度链接
1.设置直接深度链接
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
if ([[userActivity activityType]
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *incomingURL = [userActivity webpageURL];
// call the below method to resolve deep link
[ADJLinkResolution
resolveLinkWithUrl:incomingURL
resolveUrlSuffixArray:@[
@"email.example.com", @"short.example.com"
]
callback:^(NSURL* _Nullable resolvedURL) {
// add your code below to handle deep link
// (for example, open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust's servers
[BrickManager brickAdjustProcessDeeplink:resolvedURL];
}];
}
return YES;
}
设置延迟深度链接
1.设置延迟深度链接监听器
[BrickManager setBrickAdjustDelegate:self];
- (BOOL)brickAdjustDeferredDeeplinkReceived:(nullable NSURL *)deeplink {
NSLog(@"deeplink:%@",deeplink.absoluteURL);
return YES;
}
2.设置 Adjust LinkMe
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.isLinkMeEnabled = YES;
设置隐私功能
1.发送删除请求
[BrickManager brickAdjustGdprForgetMe];
2.针对特定用户的第三方分享
BrickADJThirdPartySharing *tps = [[BrickADJThirdPartySharing alloc] init];
tps.enabled = @1;
[tps addGranularOption:@"facebook" key:@"data_processing_options_country" value:@"1"];
[tps addGranularOption:@"facebook" key:@"data_processing_options_state" value:@"1000"];
[BrickManager brickAdjustTrackThirdPartySharing:tps];
3.更新合作伙伴分享设置
BrickADJThirdPartySharing *tps = [[BrickADJThirdPartySharing alloc] init];
tps.enabled = @1;
[tps addPartnerSharingSetting:@"PartnerA" key:@"all" value:NO];
[tps addPartnerSharingSetting:@"PartnerA" key:@"event" value:YES];
[BrickManager brickAdjustTrackThirdPartySharing:tps];
4.设置 URL 策略
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
NSArray *domain = [[NSArray alloc] initWithObjects:@"adjust.net.in", @"adjust.com", nil];
config.urlStrategyDomains = domain;
config.useSubdomains = YES;
config.isDataResidency = NO;
5.针对特定用户的许可监测
[BrickManager brickAdjustTrackMeasurementConsent:YES];
6.COPPA 合规
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.isCoppaComplianceEnabled = YES;
7.禁用 IDFV 读取
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.isIdfvReadingEnabled = NO;
收入验证
1.记录事件并验证购买
BrickADJEvent *event = [[BrickADJEvent alloc] init];
event.eventToken = @"yourEventToken";
event.productId = @"product-id";
event.transactionId = @"transaction-id";
[BrickManager brickAdjustVerifyAndTrackAppStorePurchase:event withCompletionHandler:^(NSDictionary * _Nonnull result) {
NSLog(@"result: %@", result);
}];
2.仅验证购买
BrickADJAppStorePurchase *appStorePurchase = [[BrickADJAppStorePurchase alloc] init];
appStorePurchase.productId = @"yourProductId";
appStorePurchase.transactionId = @"yourTranscationId";
[BrickManager brickAdjustVerifyAppStorePurchase:appStorePurchase withCompletionHandler:^(NSDictionary * _Nonnull result) {
NSLog(@"result: %@", result);
}];
配置回传参数
1.统一回传参数
[BrickManager brickAdjustAddGlobalPartnerParameter:@"value" forKey:@"key"];
2.通过 key 移除统一回传参数
[BrickManager brickAdjustRemoveGlobalCallbackParameterForKey:@"key"];
3.移除所有统一回传参数
[BrickManager brickAdjustRemoveGlobalCallbackParameters];
4.统一合作伙伴参数
[BrickManager brickAdjustAddGlobalPartnerParameter:@"Partner" forKey:@"key"];
5.按 key 移除统一合作伙伴参数
[BrickManager brickAdjustRemoveGlobalPartnerParameterForKey:@"key"];
6.移除所有统一合作伙伴参数
[BrickManager brickAdjustRemoveGlobalPartnerParameters];
解析品牌化短链接
示例:
[BrickManager brickAdjustProcessAndResolveDeeplink:[userActivity webpageURL]
withCompletionHandler:^(NSString * _Nullable resolvedLink) {
// resolvedLink contains either resolved URL (if it was unshortened)
// or just echoed URL if it was not shortened
}
];
设置 SKAdNetwork 和转化值
1.Disable SKAdNetwork communication
BrickAjustConfig *config = [[BrickAjustConfig alloc] init];
config.isSkanAttributionEnabled = NO;
2.Update conversion values
[BrickManager brickAdjustUpdateSkanConversionValue:1 coarseValue:SKAdNetworkCoarseConversionValueLow lockWindow:NO withCompletionHandler:^(NSError * _Nullable error) {
NSLog(@"An error occurred during completion: %@", error);
}];
发送订阅信息
示例:
BrickADJAppStoreSubscription *subscription = [[BrickADJAppStoreSubscription alloc] init];
subscription.price = [[NSDecimalNumber alloc] initWithInt:100];
subscription.currency = @"CNY"; subscription.transactionId = @"yourTransactionId"; subscription.transactionDate = [NSDate date];
subscription.salesRegion = @"salesRegion";
subscription.callbackParameters = @{@"key1":@"value1"};
subscription.callbackParameters = @{@"key2":@"value2"};
subscription.partnerParameters = @{@"key1":@"value1"};
subscription.partnerParameters = @{@"key2":@"value2"};
[BrickManager brickAdjustTrackAppStoreSubscription:subscription];
1.记录购买日期
subscription.transactionDate = [NSDate date];
2.记录购买地区
subscription.salesRegion = @"salesRegion";
3.添加回传参数
subscription.callbackParameters = @{@"key1":@"value1"};
4.添加合作伙伴参数
subscription.partnerParameters = @{@"key1":@"value1"};