Skip to content

Commit 683d85f

Browse files
committed
Add syncAfterSetUser setting to auto-track after user data changes
1 parent f19d9e9 commit 683d85f

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

RadarSDK/Radar.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ + (NSString *_Nullable)getPublishableKey {
128128

129129
+ (void)setUserId:(NSString *)userId {
130130
[RadarSettings setUserId:userId];
131+
132+
RadarSdkConfiguration *sdkConfiguration = [RadarSettings sdkConfiguration];
133+
if (sdkConfiguration.syncAfterSetUser) {
134+
[self trackOnceWithDesiredAccuracy:RadarTrackingOptionsDesiredAccuracyMedium beacons:NO completionHandler:nil];
135+
}
131136
}
132137

133138
+ (NSString *_Nullable)getUserId {
@@ -144,6 +149,11 @@ + (NSString *_Nullable)getDescription {
144149

145150
+ (void)setMetadata:(NSDictionary *)metadata {
146151
[RadarSettings setMetadata:metadata];
152+
153+
RadarSdkConfiguration *sdkConfiguration = [RadarSettings sdkConfiguration];
154+
if (sdkConfiguration.syncAfterSetUser) {
155+
[self trackOnceWithDesiredAccuracy:RadarTrackingOptionsDesiredAccuracyMedium beacons:NO completionHandler:nil];
156+
}
147157
}
148158

149159
+ (NSDictionary *_Nullable)getMetadata {

RadarSDK/RadarSdkConfiguration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ NS_ASSUME_NONNULL_BEGIN
3939

4040
@property (nonatomic, assign) BOOL useNotificationDiff;
4141

42+
@property (nonatomic, assign) BOOL syncAfterSetUser;
43+
4244
/**
4345
Initializes a new RadarSdkConfiguration object with given value.
4446
*/

RadarSDK/RadarSdkConfiguration.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
3333
_useOpenedAppConversion = NO;
3434
_useForegroundLocationUpdatedAtMsDiff = NO;
3535
_useNotificationDiff = NO;
36+
_syncAfterSetUser = NO;
3637

3738
if (dict == nil) {
3839
return self;
@@ -93,6 +94,11 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
9394
_useNotificationDiff = [(NSNumber *)useNotificationDiffObj boolValue];
9495
}
9596

97+
NSObject *syncAfterSetUserObj = dict[@"syncAfterSetUser"];
98+
if (syncAfterSetUserObj && [syncAfterSetUserObj isKindOfClass:[NSNumber class]]) {
99+
_syncAfterSetUser = [(NSNumber *)syncAfterSetUserObj boolValue];
100+
}
101+
96102
return self;
97103
}
98104

@@ -110,6 +116,7 @@ - (NSDictionary *)dictionaryValue {
110116
dict[@"useOpenedAppConversion"] = @(_useOpenedAppConversion);
111117
dict[@"useForegroundLocationUpdatedAtMsDiff"] = @(_useForegroundLocationUpdatedAtMsDiff);
112118
dict[@"useNotificationDiff"] = @(_useNotificationDiff);
119+
dict[@"syncAfterSetUser"] = @(_syncAfterSetUser);
113120

114121
return dict;
115122
}

RadarSDKTests/Resources/get_config_response.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"logLevel": "info",
1313
"startTrackingOnInitialize": true,
1414
"trackOnceOnAppOpen": true,
15+
"syncAfterSetUser": false
1516
}
1617
}
1718
}

0 commit comments

Comments
 (0)