Skip to content

Commit

Permalink
Merge pull request #676 from CleverTap/develop
Browse files Browse the repository at this point in the history
Release corev7.0.2
  • Loading branch information
Anush-Shand authored Oct 10, 2024
2 parents 4b1ea75 + 944f643 commit 2968228
Show file tree
Hide file tree
Showing 38 changed files with 1,396 additions and 316 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## CHANGE LOG.

### October 10, 2024
* [CleverTap Android SDK v7.0.2](docs/CTCORECHANGELOG.md)

### September 2, 2024
* [CleverTap Android SDK v7.0.1](docs/CTCORECHANGELOG.md)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ We publish the SDK to `mavenCentral` as an `AAR` file. Just declare it as depend

```groovy
dependencies {
implementation "com.clevertap.android:clevertap-android-sdk:7.0.1"
implementation "com.clevertap.android:clevertap-android-sdk:7.0.2"
}
```

Alternatively, you can download and add the AAR file included in this repo in your Module libs directory and tell gradle to install it like this:

```groovy
dependencies {
implementation (name: "clevertap-android-sdk-7.0.1", ext: 'aar')
implementation (name: "clevertap-android-sdk-7.0.2", ext: 'aar')
}
```

Expand All @@ -46,7 +46,7 @@ Add the Firebase Messaging library and Android Support Library v4 as dependencie

```groovy
dependencies {
implementation "com.clevertap.android:clevertap-android-sdk:7.0.1"
implementation "com.clevertap.android:clevertap-android-sdk:7.0.2"
implementation "androidx.core:core:1.9.0"
implementation "com.google.firebase:firebase-messaging:23.0.6"
implementation "com.google.android.gms:play-services-ads:22.3.0" // Required only if you enable Google ADID collection in the SDK (turned off by default).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import com.clevertap.android.sdk.task.CTExecutorFactory
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract

fun Context.isPackageAndOsTargetsAbove(apiLevel: Int) =
VERSION.SDK_INT > apiLevel && targetSdkVersion > apiLevel
Expand Down Expand Up @@ -299,3 +301,9 @@ fun String?.toJsonOrNull(): JSONObject? {
}
}
}

@OptIn(ExperimentalContracts::class)
fun String?.isNotNullAndBlank() : Boolean {
contract { returns(true) implies (this@isNotNullAndBlank != null) }
return isNullOrBlank().not()
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
import com.clevertap.android.sdk.inapp.CTLocalInApp;
import com.clevertap.android.sdk.inapp.callbacks.FetchInAppsCallback;
import com.clevertap.android.sdk.inapp.customtemplates.CustomTemplateContext;
import com.clevertap.android.sdk.inapp.customtemplates.FunctionPresenter;
import com.clevertap.android.sdk.inapp.customtemplates.JsonTemplatesProducer;
import com.clevertap.android.sdk.inapp.customtemplates.TemplatePresenter;
import com.clevertap.android.sdk.inapp.customtemplates.TemplateProducer;
import com.clevertap.android.sdk.inapp.customtemplates.TemplatesManager;
import com.clevertap.android.sdk.inapp.data.CtCacheType;
Expand All @@ -56,7 +59,6 @@
import com.clevertap.android.sdk.interfaces.NotificationRenderedListener;
import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
import com.clevertap.android.sdk.interfaces.SCDomainListener;
import com.clevertap.android.sdk.network.BaseNetworkManager;
import com.clevertap.android.sdk.network.NetworkManager;
import com.clevertap.android.sdk.product_config.CTProductConfigController;
import com.clevertap.android.sdk.product_config.CTProductConfigListener;
Expand Down Expand Up @@ -205,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 @@ -218,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 Expand Up @@ -1027,7 +1064,7 @@ public static void tokenRefresh(Context context, String token, PushType pushType
* {@link TemplateProducer}. See {@link com.clevertap.android.sdk.inapp.customtemplates.CustomTemplate.Builder
* CustomTemplate.Builder}. Templates must be registered before the {@link CleverTapAPI} instance, that would use
* them, is created. A common place for this initialization is in {@link Application#onCreate()}. If your
* application uses multiple {@link CleverTapAPI} instance, use the {@link CleverTapInstanceConfig} within the
* application uses multiple {@link CleverTapAPI} instances, use the {@link CleverTapInstanceConfig} within the
* TemplateProducer to differentiate which templates should be registered to which {@link CleverTapAPI}
* instances.This method can be called multiple times with different TemplateProducers, however all of the
* produced templates must have unique names.
Expand Down Expand Up @@ -1061,6 +1098,32 @@ public static synchronized void registerCustomInAppTemplates(TemplateProducer pr
TemplatesManager.register(producer);
}

/**
* Register {@link com.clevertap.android.sdk.inapp.customtemplates.CustomTemplate CustomTemplates} through a
* json definition. Templates must be registered before the {@link CleverTapAPI} instance, that would use
* them, is created. A common place for this initialization is in {@link Application#onCreate()}. If your
* application uses multiple {@link CleverTapAPI} instances, extend {@link JsonTemplatesProducer}
* with definitions for each instance and register using {@link #registerCustomInAppTemplates(TemplateProducer)}.
* Use the {@link CleverTapInstanceConfig} in {@link JsonTemplatesProducer#defineTemplates} to control
* for which instance the templates should be registered.
* </br>
* This method can be called multiple times with different json definitions and presenters,
* however all of the templates must have unique names.
*
* @param templatesJson A string with the json definitions of templates. See
* {@link JsonTemplatesProducer} for the json format.
* @param templatesPresenter A presenter for all templates in the json definitions.
* Required if there is at least one template with type "template".
* @param functionsPresenter A presenter for all functions in the json definitions.
* Required if there is at least one template with type "function".
*/
public static synchronized void registerCustomInAppTemplates
(@NonNull String templatesJson,
@Nullable TemplatePresenter templatesPresenter,
@Nullable FunctionPresenter functionsPresenter) {
TemplatesManager.register(new JsonTemplatesProducer(templatesJson, templatesPresenter, functionsPresenter));
}

/**
* Retrieve a {@link CustomTemplateContext} for a template that is currently displaying. If the provided template
* name is not of a currently active template this method returns <code>null</code>.
Expand Down Expand Up @@ -1104,7 +1167,7 @@ public void syncRegisteredInAppTemplates() {
}

TemplatesManager templatesManager = coreState.getTemplatesManager();
BaseNetworkManager networkManager = coreState.getNetworkManager();
NetworkManager networkManager = coreState.getNetworkManager();

getCleverTapID(x -> {
// getCleverTapID is executed on the main thread
Expand Down Expand Up @@ -1365,10 +1428,10 @@ public void flush() {
public void setSCDomainListener(SCDomainListener scDomainListener) {
coreState.getCallbackManager().setSCDomainListener(scDomainListener);

if(coreState.getNetworkManager() != null) {
NetworkManager networkManager = (NetworkManager) coreState.getNetworkManager();
if (coreState.getNetworkManager() != null) {
NetworkManager networkManager = coreState.getNetworkManager();
String domain = networkManager.getDomain(EventGroup.REGULAR);
if(domain != null) {
if (domain != null) {
scDomainListener.onSCDomainAvailable(getSCDomain(domain));
}
}
Expand Down Expand Up @@ -3039,6 +3102,7 @@ private static CleverTapInstanceConfig getDefaultConfig(Context context) {
String accountRegion = manifest.getAccountRegion();
String proxyDomain = manifest.getProxyDomain();
String spikyProxyDomain = manifest.getSpikeyProxyDomain();
String handshakeDomain = manifest.getHandshakeDomain();
if (accountId == null || accountToken == null) {
Logger.i(
"Account ID or Account token is missing from AndroidManifest.xml, unable to create default instance");
Expand All @@ -3055,6 +3119,9 @@ private static CleverTapInstanceConfig getDefaultConfig(Context context) {
if (spikyProxyDomain != null && !spikyProxyDomain.trim().isEmpty()) {
defaultInstanceConfig.setSpikyProxyDomain(spikyProxyDomain);
}
if (handshakeDomain != null && !handshakeDomain.trim().isEmpty()) {
defaultInstanceConfig.setCustomHandshakeDomain(handshakeDomain);
}
return defaultInstanceConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public CleverTapInstanceConfig[] newArray(int size) {

private String spikyProxyDomain;

private String customHandshakeDomain;

@NonNull
private ArrayList<String> allowedPushTypes = getAll();

Expand Down Expand Up @@ -113,6 +115,7 @@ public static CleverTapInstanceConfig createInstance(Context context, @NonNull S
this.accountRegion = config.accountRegion;
this.proxyDomain = config.proxyDomain;
this.spikyProxyDomain = config.spikyProxyDomain;
this.customHandshakeDomain = config.customHandshakeDomain;
this.isDefaultInstance = config.isDefaultInstance;
this.analyticsOnly = config.analyticsOnly;
this.personalization = config.personalization;
Expand Down Expand Up @@ -181,6 +184,9 @@ private CleverTapInstanceConfig(String jsonString) throws Throwable {
if (configJsonObject.has(Constants.KEY_SPIKY_PROXY_DOMAIN)) {
this.spikyProxyDomain = configJsonObject.getString(Constants.KEY_SPIKY_PROXY_DOMAIN);
}
if (configJsonObject.has(Constants.KEY_CUSTOM_HANDSHAKE_DOMAIN)) {
this.customHandshakeDomain = configJsonObject.optString(Constants.KEY_CUSTOM_HANDSHAKE_DOMAIN, null);
}
if (configJsonObject.has(Constants.KEY_ACCOUNT_REGION)) {
this.accountRegion = configJsonObject.getString(Constants.KEY_ACCOUNT_REGION);
}
Expand Down Expand Up @@ -243,6 +249,7 @@ private CleverTapInstanceConfig(Parcel in) {
accountRegion = in.readString();
proxyDomain = in.readString();
spikyProxyDomain = in.readString();
customHandshakeDomain = in.readString();
analyticsOnly = in.readByte() != 0x00;
isDefaultInstance = in.readByte() != 0x00;
useGoogleAdId = in.readByte() != 0x00;
Expand Down Expand Up @@ -313,6 +320,14 @@ public void setSpikyProxyDomain(String spikyProxyDomain) {
this.spikyProxyDomain = spikyProxyDomain;
}

public String getCustomHandshakeDomain() {
return customHandshakeDomain;
}

public void setCustomHandshakeDomain(String handshakeDomain) {
this.customHandshakeDomain = handshakeDomain;
}

@SuppressWarnings({"unused"})
public void setDebugLevel(CleverTapAPI.LogLevel debugLevel) {
setDebugLevel(debugLevel.intValue());
Expand Down Expand Up @@ -394,6 +409,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(accountRegion);
dest.writeString(proxyDomain);
dest.writeString(spikyProxyDomain);
dest.writeString(customHandshakeDomain);
dest.writeByte((byte) (analyticsOnly ? 0x01 : 0x00));
dest.writeByte((byte) (isDefaultInstance ? 0x01 : 0x00));
dest.writeByte((byte) (useGoogleAdId ? 0x01 : 0x00));
Expand Down Expand Up @@ -474,6 +490,7 @@ String toJSONString() {
configJsonObject.put(Constants.KEY_ACCOUNT_REGION, getAccountRegion());
configJsonObject.put(Constants.KEY_PROXY_DOMAIN, getProxyDomain());
configJsonObject.put(Constants.KEY_SPIKY_PROXY_DOMAIN, getSpikyProxyDomain());
configJsonObject.put(Constants.KEY_CUSTOM_HANDSHAKE_DOMAIN, getCustomHandshakeDomain());
configJsonObject.put(Constants.KEY_FCM_SENDER_ID, getFcmSenderId());
configJsonObject.put(Constants.KEY_ANALYTICS_ONLY, isAnalyticsOnly());
configJsonObject.put(Constants.KEY_DEFAULT_INSTANCE, isDefaultInstance());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface Constants {
String LABEL_REGION = "CLEVERTAP_REGION";
String LABEL_PROXY_DOMAIN = "CLEVERTAP_PROXY_DOMAIN";
String LABEL_SPIKY_PROXY_DOMAIN = "CLEVERTAP_SPIKY_PROXY_DOMAIN";
String LABEL_CLEVERTAP_HANDSHAKE_DOMAIN = "CLEVERTAP_HANDSHAKE_DOMAIN";
String LABEL_DISABLE_APP_LAUNCH = "CLEVERTAP_DISABLE_APP_LAUNCHED";
String LABEL_SSL_PINNING = "CLEVERTAP_SSL_PINNING";
String LABEL_BACKGROUND_SYNC = "CLEVERTAP_BACKGROUND_SYNC";
Expand Down Expand Up @@ -190,6 +191,7 @@ public interface Constants {
String KEY_ACCOUNT_REGION = "accountRegion";
String KEY_PROXY_DOMAIN = "proxyDomain";
String KEY_SPIKY_PROXY_DOMAIN = "spikyProxyDomain";
String KEY_CUSTOM_HANDSHAKE_DOMAIN = "customHandshakeDomain";
String KEY_ANALYTICS_ONLY = "analyticsOnly";
String KEY_DEFAULT_INSTANCE = "isDefaultInstance";
String KEY_USE_GOOGLE_AD_ID = "useGoogleAdId";
Expand Down
Loading

0 comments on commit 2968228

Please sign in to comment.