diff --git a/Example/Example/AppDelegate.m b/Example/Example/AppDelegate.m index cab408617..dc33bef90 100644 --- a/Example/Example/AppDelegate.m +++ b/Example/Example/AppDelegate.m @@ -57,6 +57,12 @@ - (void)SDK3rdStart { } NSLog(@"deepLinkCallback params = %@, processTime = %f", params, processTime); }; + + NSString *caid = @"[" + @"{\"caid\":\"507b36cb169864220bc22a8c522532fa\",\"version\":\"20220111\"}," + @"{\"caid\":\"e18a100398425c5026591525e844f7a7\",\"version\":\"20230330\"}" + @"]"; + configuration.CAID = caid; #endif #if defined(SDKAPMMODULE) diff --git a/GrowingTrackerCore/GrowingTrackConfiguration.m b/GrowingTrackerCore/GrowingTrackConfiguration.m index f7d53af76..16dd2cb68 100644 --- a/GrowingTrackerCore/GrowingTrackConfiguration.m +++ b/GrowingTrackerCore/GrowingTrackConfiguration.m @@ -31,6 +31,7 @@ @interface GrowingTrackConfiguration () @property (nonatomic, copy) NSString *deepLinkHost; @property (nonatomic, copy) id deepLinkCallback; @property (nonatomic, assign) BOOL readClipboardEnabled; +@property (nonatomic, copy) NSString *CAID; // APM @property (nonatomic, copy) NSObject *APMConfig; @@ -72,6 +73,7 @@ - (instancetype)initWithAccountId:(NSString *)accountId { _deepLinkHost = kGrowingDefaultDeepLinkHost; _deepLinkCallback = nil; _readClipboardEnabled = YES; + _CAID = nil; // APM _APMConfig = nil; @@ -119,6 +121,7 @@ - (id)copyWithZone:(NSZone *)zone { configuration->_deepLinkHost = [_deepLinkHost copy]; configuration->_deepLinkCallback = [_deepLinkCallback copy]; configuration->_readClipboardEnabled = _readClipboardEnabled; + configuration->_CAID = [_CAID copy]; // APM configuration->_APMConfig = [_APMConfig copy]; diff --git a/Modules/Advertising/GrowingAdvertising.m b/Modules/Advertising/GrowingAdvertising.m index 512414a52..1e074f53d 100644 --- a/Modules/Advertising/GrowingAdvertising.m +++ b/Modules/Advertising/GrowingAdvertising.m @@ -395,16 +395,21 @@ - (void)generateAppActivation { if (trackConfiguration.ASAEnabled) { [GrowingAsaFetcher startFetchWithTimeOut:GrowingAsaFetcherDefaultTimeOut]; } - + NSString *CAID = trackConfiguration.CAID; [self accessUserAgent:^(NSString *userAgent) { if ([self SDKDoNotTrack]) { return; } GrowingActivateBuilder *builder = GrowingActivateEvent.builder.setEventName(GrowingAdEventNameActivate); + NSMutableDictionary *attributes = @{}.mutableCopy; if (userAgent.length > 0) { - builder.setAttributes(@{@"userAgent": userAgent.copy}); + [attributes setObject:userAgent.copy forKey:@"userAgent"]; + } + if (CAID.length > 0) { + [attributes setObject:CAID.copy forKey:@"CAID"]; } + builder.setAttributes(attributes.copy); [[GrowingEventManager sharedInstance] postEventBuilder:builder]; [GrowingAdUtils setActivateWrote:YES]; }]; @@ -415,9 +420,15 @@ - (void)generateAppDefer:(NSDictionary *)dic { if ([self SDKDoNotTrack]) { return; } - + + NSMutableDictionary *attributes = dic.mutableCopy; + GrowingTrackConfiguration *trackConfiguration = GrowingConfigurationManager.sharedInstance.trackConfiguration; + NSString *CAID = trackConfiguration.CAID; + if (CAID.length > 0) { + [attributes setObject:CAID.copy forKey:@"CAID"]; + } GrowingActivateBuilder *builder = - GrowingActivateEvent.builder.setEventName(GrowingAdEventNameDefer).setAttributes(dic); + GrowingActivateEvent.builder.setEventName(GrowingAdEventNameDefer).setAttributes(attributes.copy); [[GrowingEventManager sharedInstance] postEventBuilder:builder]; [GrowingAdUtils setActivateWrote:YES]; [GrowingAdUtils setActivateDefer:YES]; diff --git a/Modules/Advertising/Public/GrowingAdvertising.h b/Modules/Advertising/Public/GrowingAdvertising.h index beb93c03c..5776d76d7 100644 --- a/Modules/Advertising/Public/GrowingAdvertising.h +++ b/Modules/Advertising/Public/GrowingAdvertising.h @@ -60,6 +60,19 @@ NS_SWIFT_NAME(Advertising) @property (nonatomic, copy) NSString *deepLinkHost; @property (nonatomic, copy) GrowingAdDeepLinkCallback deepLinkCallback; @property (nonatomic, assign) BOOL readClipboardEnabled; +/// 若您通过广协接口获取了CAID,请将按照如下JSON格式转为字符串传入: +/// [ +/// { +/// "version":"20220111", +/// "caid":"507b36cb169864220bc22a8c522532fa" +/// }, +/// { +/// "version":"20230330", +/// "caid":"e18a100398425c5026591525e844f7a7" +/// } +/// ] +/// +@property (nonatomic, copy) NSString *CAID; @end