Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release corev7.0.2 #676

Merged
merged 35 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
77a1e86
Add registering of custom templates through a json definition
vasct Jul 25, 2024
db5402e
feat(SDK-4042): Adds manifest tag for handshake domain
CTLalit Sep 11, 2024
6231b7f
chore(SDK-4042): Rearranges api class
CTLalit Sep 11, 2024
70853f9
feat(SDK-4042): passes custom domain to api class
CTLalit Sep 11, 2024
ef78d69
feat(SDK-4042): Rearranges api class
CTLalit Sep 12, 2024
56ee2e7
feat(SDK-4042): changes need handshake method + ctapi
CTLalit Sep 13, 2024
00bd53f
Merge pull request #653 from CleverTap/task/custom-templates-json-def…
vasct Sep 16, 2024
c95ac25
feat(SDK-4042): fixes set handshake domain + idiomatic kotlin syntax
CTLalit Sep 16, 2024
8b55b91
feat(SDK-4042): adds custom handshake header
CTLalit Sep 16, 2024
692e4c1
feat(SDK-4042): fixes pr comments
CTLalit Sep 16, 2024
0756980
feat(SDK-4042): fixes manifest
CTLalit Sep 16, 2024
639ea1f
feat(SDK-4042): removes duplicate function
CTLalit Sep 19, 2024
99e0457
chore(SDK-4042): renames method param, moves method
CTLalit Sep 19, 2024
e898603
chore(SDK-4042): changes isNullOrEmpty to isNullOrBlank
CTLalit Sep 19, 2024
0974ca6
feat(SDK-4063): fixes bug with switching configs
CTLalit Sep 19, 2024
6074804
feat(SDK-4063): test cases for ct api
CTLalit Sep 19, 2024
6d8a59c
Add registering of custom templates through a json definition
vasct Jul 25, 2024
2b280de
Merge branch 'develop' into feat/handshake-config
CTLalit Sep 19, 2024
864ea4f
feat(SDK-4063): Removes abstractions
CTLalit Sep 23, 2024
a768f32
feat(SDK-4063): Simplifies ct api logic
CTLalit Sep 24, 2024
dec8276
feat(SDK-4076): Changes need handshake logic
CTLalit Sep 27, 2024
abbdf8d
feat(SDK-4076): Removes cached handshake information
CTLalit Sep 27, 2024
abcd2ba
feat(SDK-4076): Fixes pr comments
CTLalit Sep 30, 2024
37ba220
feat(SDK-4076): removes redundant cast.
CTLalit Sep 30, 2024
f563131
Merge pull request #670 from CleverTap/feat/network-testing
CTLalit Sep 30, 2024
b168bda
Merge branch 'feat/handshake-config' into feat/handshake-config-2
CTLalit Sep 30, 2024
46e7140
feat(SDK-4076): fixes test cases for ctapi
CTLalit Sep 30, 2024
269d097
feat(SDK-4076): flaky tests in repo ignored
CTLalit Sep 30, 2024
20ed304
Merge pull request #672 from CleverTap/feat/handshake-config-2
CTLalit Oct 1, 2024
10945a1
feat(SDK-4076): Cleanup application class to test
CTLalit Oct 7, 2024
314be81
feat(SDK-4076): Adds methods to change credentials
CTLalit Oct 7, 2024
53571e1
chore(SDK-4076): fixes test
CTLalit Oct 9, 2024
8ba33de
chore(SDK-4076): ignores flaky test (unrelated)
CTLalit Oct 10, 2024
f976c6b
Merge pull request #668 from CleverTap/feat/handshake-config
CTLalit Oct 10, 2024
944f643
docs(SDK-4092): Release cadence for 7.0.2 (#675)
CTLalit Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading