Skip to content

Commit

Permalink
added setCredentials method for custom handshake domain
Browse files Browse the repository at this point in the history
  • Loading branch information
akashvercetti committed Nov 28, 2024
1 parent cc75737 commit 3c2778d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CleverTapSDK/CTPlistInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
- (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSString * _Nonnull)token region:(NSString * _Nullable)region;
- (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSString * _Nonnull)token proxyDomain:(NSString * _Nonnull)proxyDomain;
- (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSString * _Nonnull)token proxyDomain:(NSString * _Nonnull)proxyDomain spikyProxyDomain:(NSString * _Nullable)spikyProxyDomain;

- (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSString * _Nonnull)token proxyDomain:(NSString * _Nonnull)proxyDomain spikyProxyDomain:(NSString * _Nullable)spikyProxyDomain handshakeDomain:(NSString* _Nonnull)handshakeDomain;
@end
8 changes: 8 additions & 0 deletions CleverTapSDK/CTPlistInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ - (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSStri
_spikyProxyDomain = spikyProxyDomain;
}

- (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSString * _Nonnull)token proxyDomain:(NSString * _Nonnull)proxyDomain spikyProxyDomain:(NSString * _Nullable)spikyProxyDomain handshakeDomain:(NSString*)handshakeDomain {
_accountId = accountID;
_accountToken = token;
_proxyDomain = proxyDomain;
_spikyProxyDomain = spikyProxyDomain;
_handshakeDomain = handshakeDomain;
}

- (void)setEncryption:(NSString *)encryptionLevel {
if (encryptionLevel && [encryptionLevel isEqualToString:@"0"]) {
_encryptionLevel = CleverTapEncryptionNone;
Expand Down
18 changes: 18 additions & 0 deletions CleverTapSDK/CleverTap.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,24 @@ typedef void (^CleverTapFetchInAppsBlock)(BOOL success);
*/
+ (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSString * _Nonnull)token proxyDomain:(NSString * _Nonnull)proxyDomain spikyProxyDomain:(NSString * _Nonnull)spikyProxyDomain;

/*!
@method
@abstract
Sets the CleverTap AccountID, token, proxy domain URL for APIs and spiky proxy domain URL for push impression APIs
@discussion
Sets the CleverTap account credentials and proxy domain URL. Once the default shared instance is intialized subsequent calls will be ignored.
Only has effect on the default shared instance.
@param accountID the CleverTap account id
@param token the CleverTap account token
@param proxyDomain the domain of the proxy server eg: example.com or subdomain.example.com
@param spikyProxyDomain the domain of the proxy server for push impression eg: example.com or subdomain.example.com
@param handshakeDomain the domain to be used for clevertap handshake
*/
+ (void)setCredentialsWithAccountID:(NSString * _Nonnull)accountID token:(NSString * _Nonnull)token proxyDomain:(NSString * _Nonnull)proxyDomain spikyProxyDomain:(NSString * _Nonnull)spikyProxyDomain handshakeDomain:(NSString * _Nonnull)handshakeDomain;

/*!
@method
Expand Down
15 changes: 15 additions & 0 deletions CleverTapSDK/CleverTap.m
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ + (nullable instancetype)_sharedInstanceWithCleverTapID:(NSString *)cleverTapID
_defaultInstanceConfig = [[CleverTapInstanceConfig alloc] initWithAccountId:_plistInfo.accountId accountToken:_plistInfo.accountToken proxyDomain:_plistInfo.proxyDomain spikyProxyDomain:_plistInfo.spikyProxyDomain isDefaultInstance:YES];
} else if (_plistInfo.proxyDomain.length > 0) {
_defaultInstanceConfig = [[CleverTapInstanceConfig alloc] initWithAccountId:_plistInfo.accountId accountToken:_plistInfo.accountToken proxyDomain:_plistInfo.proxyDomain isDefaultInstance:YES];
} else if (_plistInfo.handshakeDomain.length > 0) {
_defaultInstanceConfig = [[CleverTapInstanceConfig alloc] initWithAccountId:_plistInfo.accountId accountToken:_plistInfo.accountToken handshakeDomain:_plistInfo.handshakeDomain isDefaultInstance:YES];
} else {
_defaultInstanceConfig = [[CleverTapInstanceConfig alloc] initWithAccountId:_plistInfo.accountId accountToken:_plistInfo.accountToken accountRegion:_plistInfo.accountRegion isDefaultInstance:YES];
}
Expand Down Expand Up @@ -3298,6 +3300,19 @@ + (void)setCredentialsWithAccountID:(NSString *)accountID token:(NSString *)toke
[_plistInfo setCredentialsWithAccountID:accountID token:token proxyDomain:proxyDomain spikyProxyDomain:finalSpikyProxyDomain];
}

+ (void)setCredentialsWithAccountID:(NSString *)accountID token:(NSString *)token proxyDomain:(NSString *)proxyDomain spikyProxyDomain:(NSString *)spikyProxyDomain handshakeDomain:(NSString *)handshakeDomain {
[self _setCredentialsWithAccountID:accountID token:token proxyDomain:proxyDomain];

NSString *finalSpikyProxyDomain;
if (spikyProxyDomain != nil && ![spikyProxyDomain isEqualToString:@""]) {
finalSpikyProxyDomain = [spikyProxyDomain stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (finalSpikyProxyDomain.length <= 0) {
finalSpikyProxyDomain = nil;
}
}
[_plistInfo setCredentialsWithAccountID:accountID token:token proxyDomain:proxyDomain spikyProxyDomain:finalSpikyProxyDomain handshakeDomain:handshakeDomain];
}

+ (void)enablePersonalization {
[self setPersonalizationEnabled:true];
}
Expand Down
18 changes: 18 additions & 0 deletions CleverTapSDK/CleverTapInstanceConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ - (instancetype)initWithAccountId:(NSString *)accountId
return self;
}

- (instancetype)initWithAccountId:(NSString *)accountId
accountToken:(NSString *)accountToken
handshakeDomain:(NSString *)handshakeDomain
isDefaultInstance:(BOOL)isDefault {
[self checkIfAvailableAccountId:accountId accountToken:accountToken];

if (self = [super init]) {
_accountId = accountId;
_accountToken = accountToken;
_handshakeDomain = handshakeDomain;
_isDefaultInstance = isDefault;
_queueLabel = [NSString stringWithFormat:@"com.clevertap.serialQueue:%@",accountId];

[self setupPlistData:isDefault];
}
return self;
}

- (instancetype)initWithAccountId:(NSString *)accountId
accountToken:(NSString *)accountToken
proxyDomain:(NSString *)proxyDomain
Expand Down
5 changes: 5 additions & 0 deletions CleverTapSDK/CleverTapInstanceConfigPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@
spikyProxyDomain:(NSString* _Nonnull)spikyProxyDomain
isDefaultInstance:(BOOL)isDefault;

- (instancetype _Nonnull)initWithAccountId:(NSString * _Nonnull)accountId
accountToken:(NSString * _Nonnull)accountToken
handshakeDomain:(NSString * _Nonnull)handshakeDomain
isDefaultInstance:(BOOL)isDefault;

+ (NSString* _Nonnull)dataArchiveFileNameWithAccountId:(NSString* _Nonnull)accountId;
@end

0 comments on commit 3c2778d

Please sign in to comment.