Skip to content

Commit

Permalink
Merge pull request #739 from CleverTap/develop
Browse files Browse the repository at this point in the history
Android SDK release 7.2.2
  • Loading branch information
piyush-kukadiya authored Jan 21, 2025
2 parents 4ff4f5f + 3aa7fc3 commit f7ce78c
Show file tree
Hide file tree
Showing 13 changed files with 620 additions and 35 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.

### January 21, 2025
* [CleverTap Android SDK v7.2.2](docs/CTCORECHANGELOG.md)

### January 16, 2025
* [CleverTap Android SDK v7.2.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.2.1"
implementation "com.clevertap.android:clevertap-android-sdk:7.2.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.2.1", ext: 'aar')
implementation (name: "clevertap-android-sdk-7.2.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.2.1"
implementation "com.clevertap.android:clevertap-android-sdk:7.2.2"
implementation "androidx.core:core:1.13.0"
implementation "com.google.firebase:firebase-messaging:24.0.0"
implementation "com.google.android.gms:play-services-ads:23.6.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 @@ -35,8 +35,6 @@
import org.json.JSONException;
import org.json.JSONObject;

import kotlin.jvm.functions.Function0;

public class AnalyticsManager extends BaseAnalyticsManager {

private final CTLockManager ctLockManager;
Expand Down Expand Up @@ -496,14 +494,14 @@ public void pushNotificationClickedEvent(final Bundle extras) {
);
if (isDuplicate) {
config.getLogger().debug(config.getAccountId(),
"Already processed Notification Clicked event for " + extras.toString()
"Already processed Notification Clicked event for " + extras
+ ", dropping duplicate.");
return;
}

try {
// convert bundle to json
JSONObject event = AnalyticsManagerBundler.notificationViewedJson(extras);
JSONObject event = AnalyticsManagerBundler.notificationClickedJson(extras);

baseEventQueueManager.queueEvent(context, event, Constants.RAISED_EVENT);
coreMetaData.setWzrkParams(AnalyticsManagerBundler.wzrkBundleToJson(extras));
Expand Down Expand Up @@ -1075,7 +1073,7 @@ private void _push(Map<String, Object> profile) {
}

config.getLogger()
.verbose(config.getAccountId(), "Constructed custom profile: " + customProfile.toString());
.verbose(config.getAccountId(), "Constructed custom profile: " + customProfile);

baseEventQueueManager.pushBasicProfile(customProfile, false);

Expand Down Expand Up @@ -1142,7 +1140,7 @@ private void _pushMultiValue(ArrayList<String> originalValues, String key, Strin
baseEventQueueManager.pushBasicProfile(fields, false);

config.getLogger()
.verbose(config.getAccountId(), "Constructed multi-value profile push: " + fields.toString());
.verbose(config.getAccountId(), "Constructed multi-value profile push: " + fields);

} catch (Throwable t) {
config.getLogger().verbose(config.getAccountId(), "Error pushing multiValue for key " + key, t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ object AnalyticsManagerBundler {
}
return event
}

@JvmStatic
fun notificationClickedJson(root: Bundle): JSONObject {
val event = JSONObject()
try {
val notif = wzrkBundleToJson(root)
event.put("evtName", Constants.NOTIFICATION_CLICKED_EVENT_NAME)
event.put("evtData", notif)
} catch (ignored: Throwable) {
//no-op
}
return event
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public final class InAppNotificationActivity extends FragmentActivity implements

private PushPermissionManager pushPermissionManager;

private boolean invokedCallbacks = false;

public interface PushPermissionResultCallback {

void onPushPermissionAccept();
Expand Down Expand Up @@ -264,13 +266,23 @@ public void onRequestPermissionsResult(
}

void didDismiss(Bundle data) {
didDismiss(data, true);
}

void didDismiss(Bundle data, boolean killActivity) {
if (isAlertVisible) {
isAlertVisible = false;
}
finish();
InAppListener listener = getListener();
if (listener != null && inAppNotification != null) {
listener.inAppNotificationDidDismiss(inAppNotification, data);

if (!invokedCallbacks) {
InAppListener listener = getListener();
if (listener != null && inAppNotification != null) {
listener.inAppNotificationDidDismiss(inAppNotification, data);
}
invokedCallbacks = true;
}
if (killActivity) {
finish();
}
}

Expand Down Expand Up @@ -449,4 +461,12 @@ private void onAlertButtonClick(CTInAppNotificationButton button, boolean isPosi

didDismiss(clickData);
}

@Override
protected void onDestroy() {
super.onDestroy();
if (!isChangingConfigurations()) {
didDismiss(null, false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.clevertap.android.sdk

import android.content.Context
import android.os.Bundle
import com.clevertap.android.sdk.AnalyticsManagerBundler.notificationClickedJson
import com.clevertap.android.sdk.AnalyticsManagerBundler.notificationViewedJson
import com.clevertap.android.sdk.events.BaseEventQueueManager
import com.clevertap.android.sdk.response.InAppResponse
Expand Down Expand Up @@ -173,7 +174,7 @@ class AnalyticsManagerTest {
@Test
fun `clevertap processes PN viewed for same wzrk_id if separated by a span of greater than 2 seconds`() {

val json = notificationViewedJson(bundleIdCheck);
val json = notificationViewedJson(bundleIdCheck)

every { timeProvider.currentTimeMillis() } returns 10000

Expand Down Expand Up @@ -225,7 +226,7 @@ class AnalyticsManagerTest {
@Test
fun `clevertap does not process duplicate (same wzrk_id) PN clicked within 2 seconds - case 2nd click happens in 200ms`() {

val json = notificationViewedJson(bundleIdCheck)
val json = notificationClickedJson(bundleIdCheck)
every { timeProvider.currentTimeMillis() } returns 0

// send PN first time
Expand Down Expand Up @@ -263,7 +264,7 @@ class AnalyticsManagerTest {
@Test
fun `clevertap processes PN clicked for same wzrk_id if separated by a span of greater than 5 seconds`() {

val json = notificationViewedJson(bundleIdCheck);
val json = notificationClickedJson(bundleIdCheck)
every { timeProvider.currentTimeMillis() } returns 10000

// send PN first time
Expand Down Expand Up @@ -354,8 +355,7 @@ class AnalyticsManagerTest {
putString("wzrk_pid", "same_pid")
}

val json1 = notificationViewedJson(notif1)
val json2 = notificationViewedJson(notif1)
val json1 = notificationClickedJson(notif1)

every { timeProvider.currentTimeMillis() } returns 0

Expand Down
Loading

0 comments on commit f7ce78c

Please sign in to comment.