Skip to content

Commit 03cf05b

Browse files
committed
Reverted back logic of caching identity if session is uninitialized.
1 parent 2c27aea commit 03cf05b

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

BranchSDK/Branch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
18571857
#endif
18581858

18591859
@property (copy, nonatomic, nullable) NSString *installUserId;
1860+
@property (copy, nonatomic, nullable) callbackWithParams setIdentityCallback;
18601861

18611862
@end
18621863

BranchSDK/Branch.m

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,11 +1049,36 @@ - (void)setIdentity:(NSString *)userId {
10491049
}
10501050

10511051
- (void)setIdentity:(NSString *)userId withCallback:(callbackWithParams)callback {
1052-
if (userId) {
1052+
if (!userId || [self.preferenceHelper.userIdentity isEqualToString:userId]) {
1053+
if (callback) {
1054+
callback([self getFirstReferringParams], nil);
1055+
}
1056+
return;
1057+
}
1058+
1059+
if (self.initializationStatus == BNCInitStatusUninitialized ) {
1060+
[self cacheIdentity:userId withCallback:callback];
1061+
} else {
10531062
self.preferenceHelper.userIdentity = userId;
1063+
if (callback) {
1064+
callback([self getFirstReferringParams], nil);
1065+
}
10541066
}
1055-
if (callback) {
1056-
callback([self getFirstReferringParams], nil);
1067+
}
1068+
1069+
- (void) cacheIdentity: (NSString *)userId withCallback:(callbackWithParams)callback {
1070+
self.installUserId = userId;
1071+
self.setIdentityCallback = callback;
1072+
}
1073+
1074+
- (void) applySavedIdentity {
1075+
if (self.installUserId != nil) {
1076+
self.preferenceHelper.userIdentity = self.installUserId;
1077+
if (self.setIdentityCallback) {
1078+
self.setIdentityCallback([self getFirstReferringParams], nil);
1079+
}
1080+
self.installUserId = nil;
1081+
self.setIdentityCallback = nil;
10571082
}
10581083
}
10591084

@@ -2262,7 +2287,8 @@ - (void)handleInitSuccessAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
22622287
}
22632288
}
22642289
[self sendOpenNotificationWithLinkParameters:latestReferringParams error:nil];
2265-
2290+
2291+
[self applySavedIdentity];
22662292

22672293
if (!self.urlFilter.hasUpdatedPatternList) {
22682294
[self.urlFilter updatePatternListWithCompletion:nil];

0 commit comments

Comments
 (0)