Skip to content

Commit

Permalink
feat(SDK-4076): Adds methods to change credentials
Browse files Browse the repository at this point in the history
- adds method for change creds for custom handshaking.
  • Loading branch information
CTLalit committed Oct 7, 2024
1 parent 10945a1 commit 314be81
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ public static void changeCredentials(String accountID, String token, String regi
* @param spikyProxyDomain CleverTap Spiky Proxy Domain
* @noinspection unused
*/
public static void changeCredentials(String accountID, String token, String proxyDomain, String spikyProxyDomain) {
public static void changeCredentials(
String accountID,
String token,
String proxyDomain,
String spikyProxyDomain
) {
if (defaultConfig != null) {
Logger.i("CleverTap SDK already initialized with accountID:" + defaultConfig.getAccountId()
+ ", token:" + defaultConfig.getAccountToken() + ", proxyDomain: " + defaultConfig.getProxyDomain() +
Expand All @@ -220,6 +225,36 @@ public static void changeCredentials(String accountID, String token, String prox
ManifestInfo.changeCredentials(accountID, token, proxyDomain, spikyProxyDomain);
}

/**
* This method is used to change the credentials of CleverTap account Id, token, proxyDomain, spikyProxyDomain programmatically
*
* @param accountID CleverTap Account Id
* @param token CleverTap Account Token
* @param proxyDomain CleverTap Proxy Domain
* @param spikyProxyDomain CleverTap Spiky Proxy Domain
* @param customHandshakeDomain Custom handshake Domain
* @noinspection unused
*/
public static void changeCredentials(
String accountID,
String token,
String proxyDomain,
String spikyProxyDomain,
String customHandshakeDomain
) {
if (defaultConfig != null) {
Logger.i("CleverTap SDK already initialized with accountID:" + defaultConfig.getAccountId()
+ ", token:" + defaultConfig.getAccountToken() + ", proxyDomain: " + defaultConfig.getProxyDomain() +
", spikyDomain: " + defaultConfig.getSpikyProxyDomain() + ", handshakeDomain: " + defaultConfig.getCustomHandshakeDomain()
+ ". Cannot change credentials to accountID: " + accountID +
", token: " + token + ", proxyDomain: " + proxyDomain + ", spikyProxyDomain: " + spikyProxyDomain
+ "and customHandshakeDomain: " + customHandshakeDomain);
return;
}

ManifestInfo.changeCredentials(accountID, token, proxyDomain, spikyProxyDomain, customHandshakeDomain);
}

/**
* Launches an asynchronous task to download the notification icon from CleverTap,
* and create the Android notification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ static void changeCredentials(String id, String token, String _proxyDomain, Stri
spikyProxyDomain = _spikyProxyDomain;
}

static void changeCredentials(String id, String token, String _proxyDomain, String _spikyProxyDomain, String customHandshakeDomain) {
accountId = id;
accountToken = token;
proxyDomain = _proxyDomain;
spikyProxyDomain = _spikyProxyDomain;
handshakeDomain = customHandshakeDomain;
}

/**
* This returns string representation of int,boolean,string,float value of given key
*
Expand Down
3 changes: 2 additions & 1 deletion sample/src/main/java/com/clevertap/demo/MyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class MyApplication : MultiDexApplication(), CTPushNotificationListener, Activit
"YOUR CLEVERTAP ACCOUNT ID",
"YOUR CLEVERTAP TOKEN",
"YOUR PROXY DOMAIN",
"YOUR SPIKY PROXY DOMAIN"
"YOUR SPIKY PROXY DOMAIN",
"YOUR CUSTOM HANDSHAKE DOMAIN"
)
}

Expand Down

0 comments on commit 314be81

Please sign in to comment.