Skip to content

Commit

Permalink
Merge pull request #309 from CleverTap/develop
Browse files Browse the repository at this point in the history
Release core 4.6.0 and push templates 1.0.4 SDK-1736
  • Loading branch information
piyush-kukadiya authored Aug 4, 2022
2 parents f8a526c + 9095498 commit 27d1f29
Show file tree
Hide file tree
Showing 42 changed files with 1,002 additions and 202 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ build/
.gradle/
*.exec
sample/google-services.json
ct_signing_key.gpg
ct_signing_key.gpg
/sample/release/sample-release.aab
/sample/libs/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## CHANGE LOG.

### August 4, 2022

* [CleverTap Android SDK v4.6.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
* [CleverTap Push Templates SDK v1.0.4](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTPUSHTEMPLATESCHANGELOG.md)

### July 22, 2022

* [CleverTap Android SDK v4.5.2](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

# CleverTap Android SDKs
[![Build Status](https://app.bitrise.io/app/09efc6b9404a6341/status.svg?token=TejL3E1NHyTiR5ajHKGJ6Q)](https://app.bitrise.io/app/09efc6b9404a6341)
[![build - pr raised against develop](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_from_task_to_develop.yml/badge.svg)](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_from_task_to_develop.yml)
[![build - master](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_merged_in_master.yml/badge.svg)](https://github.com/CleverTap/clevertap-android-sdk/actions/workflows/on_pr_merged_in_master.yml)
[![Download](https://api.bintray.com/packages/clevertap/Maven/CleverTapAndroidSDK/images/download.svg) ](https://bintray.com/clevertap/Maven/CleverTapAndroidSDK/_latestVersion)

## 👋 Introduction
Expand All @@ -26,15 +24,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:4.5.2"
implementation "com.clevertap.android:clevertap-android-sdk:4.6.0"
}
```

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-4.5.2", ext: 'aar')
implementation (name: "clevertap-android-sdk-4.6.0", ext: 'aar')
}
```

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

```groovy
dependencies {
implementation "com.clevertap.android:clevertap-android-sdk:4.5.2"
implementation "com.clevertap.android:clevertap-android-sdk:4.6.0"
implementation "androidx.core:core:1.3.0"
implementation "com.google.firebase:firebase-messaging:21.0.0"
implementation "com.google.android.gms:play-services-ads:19.4.0" // Required only if you enable Google ADID collection in the SDK (turned off by default).
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ buildscript {
classpath Libs.agcp// Huawei Push Plugin
classpath Libs.kotlin_gradle_plugin
classpath Libs.sonarqube_gradle_plugin
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.20.0-RC1")
classpath("com.vanniktech:gradle-android-junit-jacoco-plugin:0.16.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.clevertap.android.sdk.displayunits.DisplayUnitListener;
import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
import com.clevertap.android.sdk.interfaces.DCDomainCallback;
import com.clevertap.android.sdk.interfaces.NotificationRenderedListener;
import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
import com.clevertap.android.sdk.product_config.CTProductConfigListener;
import com.clevertap.android.sdk.pushnotification.CTPushNotificationListener;
Expand Down Expand Up @@ -74,4 +75,8 @@ public abstract void setPushNotificationListener(
public abstract OnInitCleverTapIDListener getOnInitCleverTapIDListener();

public abstract void setOnInitCleverTapIDListener(OnInitCleverTapIDListener onInitCleverTapIDListener);

public abstract void setNotificationRenderedListener(NotificationRenderedListener notificationRenderedListener);

public abstract NotificationRenderedListener getNotificationRenderedListener();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.clevertap.android.sdk.displayunits.DisplayUnitListener;
import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
import com.clevertap.android.sdk.interfaces.DCDomainCallback;
import com.clevertap.android.sdk.interfaces.NotificationRenderedListener;
import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
import com.clevertap.android.sdk.product_config.CTProductConfigListener;
import com.clevertap.android.sdk.pushnotification.CTPushNotificationListener;
Expand Down Expand Up @@ -37,6 +38,8 @@ public class CallbackManager extends BaseCallbackManager {

private WeakReference<CTFeatureFlagsListener> featureFlagListenerWeakReference;

private NotificationRenderedListener notificationRenderedListener;

private OnInitCleverTapIDListener onInitCleverTapIDListener;

private WeakReference<CTProductConfigListener> productConfigListener;
Expand Down Expand Up @@ -199,6 +202,16 @@ public void setOnInitCleverTapIDListener(final OnInitCleverTapIDListener onInitC
this.onInitCleverTapIDListener = onInitCleverTapIDListener;
}

@Override
public void setNotificationRenderedListener(final NotificationRenderedListener notificationRenderedListener) {
this.notificationRenderedListener = notificationRenderedListener;
}

@Override
public NotificationRenderedListener getNotificationRenderedListener() {
return notificationRenderedListener;
}

//Profile
@Override
public void notifyUserProfileInitialized(String deviceID) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.clevertap.android.sdk;

import static android.content.Context.NOTIFICATION_SERVICE;

import static com.clevertap.android.sdk.Utils.getDCDomain;

import static com.clevertap.android.sdk.pushnotification.PushConstants.FCM_LOG_TAG;
import static com.clevertap.android.sdk.pushnotification.PushConstants.LOG_TAG;
import static com.clevertap.android.sdk.pushnotification.PushConstants.PushType.FCM;
Expand Down Expand Up @@ -38,6 +36,7 @@
import com.clevertap.android.sdk.inbox.CTMessageDAO;
import com.clevertap.android.sdk.interfaces.DCDomainCallback;
import com.clevertap.android.sdk.interfaces.NotificationHandler;
import com.clevertap.android.sdk.interfaces.NotificationRenderedListener;
import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
import com.clevertap.android.sdk.network.NetworkManager;
import com.clevertap.android.sdk.product_config.CTProductConfigController;
Expand All @@ -57,7 +56,6 @@
import com.clevertap.android.sdk.validation.ValidationResult;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.firebase.messaging.FirebaseMessaging;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -90,7 +88,7 @@ public interface DevicePushTokenRefreshListener {
/**
* Implement to get called back when the device push token is received
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
@RestrictTo(Scope.LIBRARY)
public interface RequestDevicePushTokenListener {

/**
Expand Down Expand Up @@ -122,7 +120,7 @@ public int intValue() {
@SuppressWarnings("unused")
public static final String NOTIFICATION_TAG = "wzrk_pn";

private static int debugLevel = CleverTapAPI.LogLevel.INFO.intValue();
private static int debugLevel = LogLevel.INFO.intValue();

static CleverTapInstanceConfig defaultConfig;

Expand Down Expand Up @@ -199,11 +197,25 @@ public static void changeXiaomiCredentials(String xiaomiAppID, String xiaomiAppK
public static void createNotification(final Context context, final Bundle extras, final int notificationId) {
CleverTapAPI instance = fromBundle(context, extras);
if (instance != null) {

CoreState coreState = instance.coreState;
CleverTapInstanceConfig config = coreState.getConfig();

try {
instance.coreState.getPushProviders().setPushNotificationRenderer(new CoreNotificationRenderer());
instance.coreState.getPushProviders()._createNotification(context, extras, notificationId);
Task<Void> task = CTExecutorFactory.executors(config).postAsyncSafelyTask();
task.execute("CleverTapAPI#createNotification",
new Callable<Void>() {
@Override
public Void call() {
synchronized (coreState.getPushProviders().getPushRenderingLock()) {
coreState.getPushProviders().setPushNotificationRenderer(new CoreNotificationRenderer());
coreState.getPushProviders()._createNotification(context, extras, notificationId);
}
return null;
}
});
} catch (Throwable t) {
// no-op
config.getLogger().debug(config.getAccountId(), "Failed to process createNotification()", t);
}
}
}
Expand Down Expand Up @@ -647,7 +659,7 @@ public Void call() {
in the presence of Custom FCM Sender ID present in the AndroidManifest.xml.
Deprecated now as we can directly call tokenRefresh method from onNewToken implementation
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@RestrictTo(Scope.LIBRARY_GROUP)
@Deprecated
public static void fcmTokenRefresh(Context context, String token) {

Expand All @@ -663,7 +675,7 @@ public static void fcmTokenRefresh(Context context, String token) {
/**
* Returns the log level set for CleverTapAPI
*
* @return The {@link CleverTapAPI.LogLevel} int value
* @return The {@link LogLevel} int value
*/
@SuppressWarnings("WeakerAccess")
public static int getDebugLevel() {
Expand Down Expand Up @@ -779,7 +791,7 @@ public static NotificationInfo getNotificationInfo(final Bundle extras) {
}

// other static handlers
@RestrictTo(RestrictTo.Scope.LIBRARY)
@RestrictTo(Scope.LIBRARY)
public static void handleNotificationClicked(Context context, Bundle notification) {
if (notification == null) {
return;
Expand Down Expand Up @@ -953,7 +965,7 @@ private static CleverTapAPI fromBundle(final Context context, final Bundle extra
return fromAccountId(context, _accountId);
}

@RestrictTo(RestrictTo.Scope.LIBRARY)
@RestrictTo(Scope.LIBRARY)
public static void runBackgroundIntentService(Context context) {
if (instances == null) {
CleverTapAPI instance = CleverTapAPI.getDefaultInstance(context);
Expand Down Expand Up @@ -983,7 +995,7 @@ public static void runBackgroundIntentService(Context context) {
}
}

@RestrictTo(RestrictTo.Scope.LIBRARY)
@RestrictTo(Scope.LIBRARY)
public static void runJobWork(Context context, JobParameters parameters) {
if (instances == null) {
CleverTapAPI instance = CleverTapAPI.getDefaultInstance(context);
Expand All @@ -1010,7 +1022,7 @@ public static void runJobWork(Context context, JobParameters parameters) {
}
}

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@RestrictTo(Scope.LIBRARY_GROUP)
public static void tokenRefresh(Context context, String token, PushType pushType) {
for (CleverTapAPI instance : getAvailableInstances(context)) {
instance.coreState.getPushProviders().doTokenRefresh(token, pushType);
Expand Down Expand Up @@ -1710,7 +1722,7 @@ public Object getProperty(String name) {
/**
* Returns the token for a particular push type
*/
public String getPushToken(@NonNull PushConstants.PushType pushType) {
public String getPushToken(@NonNull PushType pushType) {
return coreState.getPushProviders().getCachedToken(pushType);
}

Expand Down Expand Up @@ -2375,6 +2387,16 @@ public void setInboxMessageButtonListener(InboxMessageButtonListener listener) {
this.inboxMessageButtonListener = new WeakReference<>(listener);
}

@RestrictTo(Scope.LIBRARY_GROUP)
public void setNotificationRenderedListener(final NotificationRenderedListener notificationRenderedListener) {
coreState.getCallbackManager().setNotificationRenderedListener(notificationRenderedListener);
}

@RestrictTo(Scope.LIBRARY_GROUP)
public NotificationRenderedListener getNotificationRenderedListener() {
return coreState.getCallbackManager().getNotificationRenderedListener();
}

/**
* Not to be used by developers. This is used internally to help CleverTap know which library is wrapping the
* native SDK
Expand Down Expand Up @@ -2542,6 +2564,16 @@ public void suspendInAppNotifications() {
}
}

@RestrictTo(Scope.LIBRARY_GROUP)
public int getCustomSdkVersion(String customSdkName) {
return coreState.getCoreMetaData().getCustomSdkVersion(customSdkName);
}

@RestrictTo(Scope.LIBRARY_GROUP)
public void setCustomSdkVersion(String customSdkName,int customSdkVersion) {
coreState.getCoreMetaData().setCustomSdkVersion(customSdkName,customSdkVersion);
}

//To be called from DeviceInfo AdID GUID generation
void deviceIDCreated(String deviceId) {

Expand Down Expand Up @@ -2833,15 +2865,35 @@ public Void call() throws Exception {
});
}

//TODO: start synchronizing entire flow from here
public void renderPushNotification(@NonNull INotificationRenderer iNotificationRenderer, Context context,
Bundle extras) {
coreState.getPushProviders().setPushNotificationRenderer(iNotificationRenderer);

if (extras != null && extras.containsKey(Constants.PT_NOTIF_ID)) {
coreState.getPushProviders()._createNotification(context, extras, extras.getInt(Constants.PT_NOTIF_ID));
} else {
coreState.getPushProviders()._createNotification(context, extras, Constants.EMPTY_NOTIFICATION_ID);
CleverTapInstanceConfig config = coreState.getConfig();

try {
Task<Void> task = CTExecutorFactory.executors(config).postAsyncSafelyTask();
task.execute("CleverTapAPI#renderPushNotification",
new Callable<Void>() {
@Override
public Void call() {
synchronized (coreState.getPushProviders().getPushRenderingLock()) {
coreState.getPushProviders().setPushNotificationRenderer(iNotificationRenderer);

if (extras != null && extras.containsKey(Constants.PT_NOTIF_ID)) {
coreState.getPushProviders()
._createNotification(context, extras, extras.getInt(Constants.PT_NOTIF_ID));
} else {
coreState.getPushProviders()._createNotification(context, extras, Constants.EMPTY_NOTIFICATION_ID);
}
}
return null;
}
});
} catch (Throwable t) {
config.getLogger().debug(config.getAccountId(), "Failed to process renderPushNotification()", t);
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,15 @@ public interface Constants {
String KEY_CT_TYPE = "ct_type";
String PT_INPUT_KEY = "pt_input_reply";

// ==========Fallback keys=========
String NOTIFICATION_HEALTH = "wzrk_pn_h";
String WZRK_TSR_FB = "wzrk_tsr_fb";// terminate and stay resident
String NOTIFICATION_RENDER_FALLBACK = "wzrk_fallback";

/**
* Device app bucket when notification is rendered
*/
String WZRK_HEALTH_STATE_GOOD = "true";
String WZRK_HEALTH_STATE_BAD = "false";

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import org.json.JSONObject;

/**
Expand Down Expand Up @@ -56,6 +57,8 @@ public class CoreMetaData extends CleverTapMetaData {

private final Object optOutFlagLock = new Object();

private HashMap<String,Integer> customSdkVersions = new HashMap<>();

private long referrerClickTime = 0;

private String source = null, medium = null, campaign = null;
Expand Down Expand Up @@ -169,6 +172,19 @@ public void setGeofenceSDKVersion(int geofenceSDKVersion) {
this.geofenceSDKVersion = geofenceSDKVersion;
}

public int getCustomSdkVersion(String customSdkName) {
Integer version = customSdkVersions.get(customSdkName);
return version!=null ? version : 0;
}

public void setCustomSdkVersion(String customSdkName,int customSdkVersion) {
customSdkVersions.put(customSdkName,customSdkVersion);
}

public HashMap<String,Integer> getAllCustomSdkVersions(){
return customSdkVersions;
}

public int getDirectCallSDKVersion() {
return directCallSDKVersion;
}
Expand Down
Loading

0 comments on commit 27d1f29

Please sign in to comment.