-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from CleverTap/feature/SDK-394-phone-identity
Added methods to allow the user to choose Identifier keys for OnUserLogin via plist or Config
- Loading branch information
Showing
306 changed files
with
3,584 additions
and
18,753 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,6 @@ ObjCStarter/Podfile.lock | |
|
||
# Swift Package Manager | ||
Package.resolved | ||
|
||
Pods | ||
Podfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
CleverTapSDK.xcodeproj/xcshareddata/xcschemes/CleverTapSDK.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
CleverTapSDK.xcodeproj/xcshareddata/xcschemes/CleverTapSDK_TVOS.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mple.xcworkspace/contents.xcworkspacedata → ...pSDK.xcworkspace/contents.xcworkspacedata
100755 → 100644
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// CTFlexibleIdentityRepo.h | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "CTIdentityRepo.h" | ||
#import "CleverTapInstanceConfig.h" | ||
#import "CTDeviceInfo.h" | ||
#import "CTValidationResultStack.h" | ||
|
||
@interface CTFlexibleIdentityRepo : NSObject<CTIdentityRepo> | ||
- (instancetype)initWithConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// | ||
// CTFlexibleIdentityRepo.m | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import "CTFlexibleIdentityRepo.h" | ||
#import "CTConstants.h" | ||
#import "CTLoginInfoProvider.h" | ||
#import "CleverTapInstanceConfigPrivate.h" | ||
|
||
|
||
@interface CTFlexibleIdentityRepo () {} | ||
@property (nonatomic, strong) NSArray *identities; | ||
@property (nonatomic, strong) CleverTapInstanceConfig *config; | ||
@property (nonatomic, strong) CTDeviceInfo *deviceInfo; | ||
@property (nonatomic, strong) CTValidationResultStack *validationResultStack; | ||
@property (nonatomic, strong) CTLoginInfoProvider *loginInfoProvider; | ||
@end | ||
|
||
@implementation CTFlexibleIdentityRepo | ||
|
||
- (instancetype)initWithConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.config = config; | ||
self.deviceInfo = deviceInfo; | ||
self.validationResultStack = validationResultStack; | ||
self.loginInfoProvider = [[CTLoginInfoProvider alloc]initWithDeviceInfo:deviceInfo config:config]; | ||
[self loadIdentities]; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSArray *)getIdentities { | ||
return self.identities; | ||
} | ||
|
||
- (BOOL)isIdentity:(NSString *)key { | ||
return [self.identities containsObject:key]; | ||
} | ||
|
||
- (void)loadIdentities { | ||
// CHECK IF ITS A LEGACY USER | ||
NSString *cachedIdentities = [self.loginInfoProvider getCachedIdentities]; | ||
NSArray *finalIdentityKeys; | ||
|
||
// NEW USER | ||
// GET IDENTIFIERS FROM PLIST IF DEFAULT INSTANCE ELSE CONFIG SETTER | ||
NSArray *configIdentifiers = [self getConfigIdentifiers]; | ||
|
||
// RAISE ERROR IF CACHED AND PLIST IDENTITIES ARE NOT EQUAL | ||
NSArray *cachedIdentityKeys = [cachedIdentities componentsSeparatedByString: @","]; | ||
if (cachedIdentityKeys.count > 0 && ![cachedIdentityKeys isEqualToArray: configIdentifiers]) { | ||
CTValidationResult *error = [[CTValidationResult alloc] init]; | ||
NSString *errString = @"Profile Identifiers mismatch with the previously saved ones"; | ||
[error setErrorCode:531]; | ||
[error setErrorDesc:errString]; | ||
[self.validationResultStack pushValidationResult:error]; | ||
CleverTapLogDebug(self.config.logLevel, @"%@: %@", self, errString); | ||
} | ||
|
||
// USE CACHED IDENTITIES IF AVAILABLE, ELSE USE PLIST/SETTER, ELSE USE DEFAULT CONSTANTS | ||
if (cachedIdentityKeys && cachedIdentityKeys.count > 0) { | ||
finalIdentityKeys = cachedIdentityKeys; | ||
} | ||
else if (configIdentifiers && configIdentifiers.count > 0) { | ||
finalIdentityKeys = configIdentifiers; | ||
} | ||
else { | ||
finalIdentityKeys = CLTAP_PROFILE_IDENTIFIER_KEYS; | ||
} | ||
|
||
// SAVE IDENTITIES TO CACHE IF NOT ALREADY | ||
if (!cachedIdentityKeys || cachedIdentityKeys.count == 0) { | ||
[self.loginInfoProvider setCachedIdentities: [configIdentifiers componentsJoinedByString: @","]]; | ||
} | ||
self.identities = finalIdentityKeys; | ||
} | ||
|
||
- (NSArray *)getConfigIdentifiers { | ||
// IF DEFAULT INSTANCE, GET KEYS FROM PLIST, ELSE GET FROM SETTER | ||
if (self.config.isDefaultInstance) { | ||
// ONLY ADD SUPPORTED KEYS | ||
NSArray *clevertapIdentifiers = [[NSBundle mainBundle].infoDictionary objectForKey:@"CleverTapIdentifiers"]; | ||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self IN %@", CLTAP_ALL_PROFILE_IDENTIFIER_KEYS]; | ||
NSArray *result = [clevertapIdentifiers filteredArrayUsingPredicate:predicate]; | ||
return result; | ||
} | ||
else { | ||
return self.config.identityKeys; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// CTIdentityRepo.h | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@protocol CTIdentityRepo <NSObject> | ||
|
||
- (NSArray*)getIdentities; | ||
- (BOOL)isIdentity: (NSString*)key; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// CTIdentityRepoFactory.h | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "CTIdentityRepo.h" | ||
#import "CleverTapInstanceConfig.h" | ||
#import "CTDeviceInfo.h" | ||
#import "CTValidationResultStack.h" | ||
|
||
@interface CTIdentityRepoFactory : NSObject | ||
|
||
+ (id<CTIdentityRepo>)getRepoForConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// CTIdentityRepoFactory.m | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import "CTIdentityRepoFactory.h" | ||
#import "CTLoginInfoProvider.h" | ||
#import "CTLegacyIdentityRepo.h" | ||
#import "CTFlexibleIdentityRepo.h" | ||
|
||
@implementation CTIdentityRepoFactory | ||
|
||
+ (id<CTIdentityRepo>)getRepoForConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack { | ||
|
||
id<CTIdentityRepo> identityRepo; | ||
CTLoginInfoProvider *loginInfoProvider = [[CTLoginInfoProvider alloc]initWithDeviceInfo:deviceInfo config:config]; | ||
if ([loginInfoProvider isLegacyProfileLoggedIn]) { | ||
identityRepo = [[CTLegacyIdentityRepo alloc]init]; | ||
} | ||
else { | ||
identityRepo = [[CTFlexibleIdentityRepo alloc]initWithConfig:config deviceInfo:deviceInfo validationResultStack:validationResultStack]; | ||
} | ||
return identityRepo; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// CTLegacyIdentityRepo.h | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "CTIdentityRepo.h" | ||
|
||
@interface CTLegacyIdentityRepo : NSObject<CTIdentityRepo> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// CTLegacyIdentityRepo.m | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import "CTLegacyIdentityRepo.h" | ||
#import "CTConstants.h" | ||
|
||
@interface CTLegacyIdentityRepo () {} | ||
@property (nonatomic, strong) NSArray *identities; | ||
@end | ||
|
||
@implementation CTLegacyIdentityRepo | ||
|
||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.identities = CLTAP_PROFILE_IDENTIFIER_KEYS; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSArray *)getIdentities { | ||
return self.identities; | ||
} | ||
|
||
- (BOOL)isIdentity:(NSString *)key { | ||
return [self.identities containsObject:key]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// CTLoginInfoProvider.h | ||
// CleverTapSDK | ||
// | ||
// Created by Akash Malhotra on 05/12/21. | ||
// Copyright © 2021 CleverTap. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "CTDeviceInfo.h" | ||
#import "CleverTapInstanceConfig.h" | ||
|
||
@interface CTLoginInfoProvider : NSObject | ||
|
||
- (void)cacheGUID:(NSString *)guid forKey:(NSString *)key andIdentifier:(NSString *)identifier; | ||
- (BOOL)deviceIsMultiUser; | ||
- (NSDictionary *)getCachedGUIDs; | ||
- (void)setCachedGUIDs:(NSDictionary *)cache; | ||
- (NSString *)getCachedIdentities; | ||
- (NSString *)getGUIDforKey:(NSString *)key andIdentifier:(NSString *)identifier; | ||
- (BOOL)isAnonymousDevice; | ||
- (BOOL)isLegacyProfileLoggedIn; | ||
- (void)setCachedIdentities:(NSString *)cache; | ||
- (instancetype)initWithDeviceInfo:(CTDeviceInfo*)deviceInfo config:(CleverTapInstanceConfig*)config; | ||
|
||
@end |
Oops, something went wrong.