Skip to content

Commit

Permalink
Merge pull request #373 from CleverTap/develop
Browse files Browse the repository at this point in the history
Release core 4.7.1 | push templates 1.0.7
  • Loading branch information
piyush-kukadiya authored Dec 5, 2022
2 parents f661781 + 60a137f commit 5bc210d
Show file tree
Hide file tree
Showing 26 changed files with 218 additions and 178 deletions.
1 change: 0 additions & 1 deletion .github/workflows/manually_validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ on:

jobs:
lint-static_checks-test-build:
if: github.head_ref == 'develop'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGE LOG.

### December 5, 2022
* [CleverTap Android SDK v4.7.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
* [CleverTap Push Templates SDK v1.0.7](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTPUSHTEMPLATESCHANGELOG.md)

### November 1, 2022
* [CleverTap Android SDK v4.7.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md)
* [CleverTap Geofence SDK v1.2.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTGEOFENCECHANGELOG.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:4.7.0"
implementation "com.clevertap.android:clevertap-android-sdk:4.7.1"
}
```

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.7.0", ext: 'aar')
implementation (name: "clevertap-android-sdk-4.7.1", 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:4.7.0"
implementation "com.clevertap.android:clevertap-android-sdk:4.7.1"
implementation "androidx.core:core:1.9.0"
implementation "com.google.firebase:firebase-messaging:23.0.6"
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
3 changes: 3 additions & 0 deletions clevertap-core/consumer-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
-keep class com.google.android.exoplayer2.ui.StyledPlayerView{*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{*;}
-keep class com.google.android.gms.common.GooglePlayServicesUtil{*;}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,44 @@ public void onInstallReferrerServiceDisconnected() {
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerClient.InstallReferrerResponse.OK:
// Connection established.
ReferrerDetails response;
try {
response = referrerClient.getInstallReferrer();
String referrerUrl = response.getInstallReferrer();
coreMetaData
.setReferrerClickTime(response.getReferrerClickTimestampSeconds());
coreMetaData
.setAppInstallTime(response.getInstallBeginTimestampSeconds());
analyticsManager.pushInstallReferrer(referrerUrl);
coreMetaData.setInstallReferrerDataSent(true);
config.getLogger().debug(config.getAccountId(),
"Install Referrer data set [Referrer URL-" + referrerUrl + "]");
} catch (RemoteException e) {
config.getLogger().debug(config.getAccountId(),
"Remote exception caused by Google Play Install Referrer library - " + e
.getMessage());
referrerClient.endConnection();
coreMetaData.setInstallReferrerDataSent(false);
}catch (NullPointerException npe){
config.getLogger().debug(config.getAccountId(),
"Install referrer client null pointer exception caused by Google Play Install Referrer library - " + npe
.getMessage());
referrerClient.endConnection();
coreMetaData.setInstallReferrerDataSent(false);
}
// Connection established
Task<ReferrerDetails> task = CTExecutorFactory.executors(config).postAsyncSafelyTask();

task.addOnSuccessListener(response -> {
try {
String referrerUrl = response.getInstallReferrer();
coreMetaData
.setReferrerClickTime(response.getReferrerClickTimestampSeconds());
coreMetaData
.setAppInstallTime(response.getInstallBeginTimestampSeconds());
analyticsManager.pushInstallReferrer(referrerUrl);
coreMetaData.setInstallReferrerDataSent(true);
config.getLogger().debug(config.getAccountId(),
"Install Referrer data set [Referrer URL-" + referrerUrl + "]");
} catch (NullPointerException npe) {
config.getLogger().debug(config.getAccountId(),
"Install referrer client null pointer exception caused by Google Play Install Referrer library - "
+ npe
.getMessage());
referrerClient.endConnection();
coreMetaData.setInstallReferrerDataSent(false);
}
});

task.execute("ActivityLifeCycleManager#getInstallReferrer", () -> {
ReferrerDetails response = null;
try {
response = referrerClient.getInstallReferrer();
} catch (RemoteException e) {
config.getLogger().debug(config.getAccountId(),
"Remote exception caused by Google Play Install Referrer library - " + e
.getMessage());
referrerClient.endConnection();
coreMetaData.setInstallReferrerDataSent(false);
}
return response;
});

break;
case InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
// API not available on the current Play Store app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.clevertap.android.sdk.pushnotification.CTPushNotificationListener;
import com.clevertap.android.sdk.pushnotification.amp.CTPushAmpListener;
import java.util.ArrayList;
import java.util.List;

public abstract class BaseCallbackManager {

Expand All @@ -28,7 +29,7 @@ public abstract class BaseCallbackManager {

public abstract InAppNotificationListener getInAppNotificationListener();

public abstract PushPermissionResponseListener getPushPermissionResponseListener();
public abstract List<PushPermissionResponseListener> getPushPermissionResponseListenerList();

public abstract CTInboxListener getInboxListener();

Expand Down Expand Up @@ -62,7 +63,9 @@ public abstract void setInAppNotificationButtonListener(

public abstract void setInAppNotificationListener(InAppNotificationListener inAppNotificationListener);

public abstract void setPushPermissionResponseListener(PushPermissionResponseListener pushPermissionResponseListener);
public abstract void unregisterPushPermissionResponseListener(PushPermissionResponseListener pushPermissionResponseListener);

public abstract void registerPushPermissionResponseListener(PushPermissionResponseListener pushPermissionResponseListener);

public abstract void setInboxListener(CTInboxListener inboxListener);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.clevertap.android.sdk.pushnotification.amp.CTPushAmpListener;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

@RestrictTo(Scope.LIBRARY)
public class CallbackManager extends BaseCallbackManager {
Expand All @@ -28,7 +29,7 @@ public class CallbackManager extends BaseCallbackManager {

private InAppNotificationListener inAppNotificationListener;

private PushPermissionResponseListener pushPermissionResponseListener;
private final List<PushPermissionResponseListener> pushPermissionResponseListenerList = new ArrayList<>();

private CTInboxListener inboxListener;

Expand Down Expand Up @@ -134,8 +135,8 @@ public InAppNotificationListener getInAppNotificationListener() {
}

@Override
public PushPermissionResponseListener getPushPermissionResponseListener() {
return pushPermissionResponseListener;
public List<PushPermissionResponseListener> getPushPermissionResponseListenerList() {
return pushPermissionResponseListenerList;
}

@Override
Expand All @@ -144,8 +145,13 @@ public void setInAppNotificationListener(final InAppNotificationListener inAppNo
}

@Override
public void setPushPermissionResponseListener(PushPermissionResponseListener pushPermissionResponseListener) {
this.pushPermissionResponseListener = pushPermissionResponseListener;
public void registerPushPermissionResponseListener(PushPermissionResponseListener pushPermissionResponseListener) {
this.pushPermissionResponseListenerList.add(pushPermissionResponseListener);
}

@Override
public void unregisterPushPermissionResponseListener(PushPermissionResponseListener pushPermissionResponseListener) {
this.pushPermissionResponseListenerList.remove(pushPermissionResponseListener);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import org.json.JSONArray;
import org.json.JSONObject;
Expand Down Expand Up @@ -127,7 +129,7 @@ public int intValue() {

static CleverTapInstanceConfig defaultConfig;

private static HashMap<String, CleverTapAPI> instances;
private static ConcurrentHashMap<String, CleverTapAPI> instances;

@SuppressWarnings({"FieldCanBeLocal", "unused"})
private static String sdkVersion; // For Google Play Store/Android Studio analytics
Expand Down Expand Up @@ -770,11 +772,11 @@ private static CleverTapAPI fromAccountId(final Context context, final String _a
return null;// failed to get instance
}

public static HashMap<String, CleverTapAPI> getInstances() {
public static ConcurrentHashMap<String, CleverTapAPI> getInstances() {
return instances;
}

public static void setInstances(final HashMap<String, CleverTapAPI> instances) {
public static void setInstances(final ConcurrentHashMap<String, CleverTapAPI> instances) {
CleverTapAPI.instances = instances;
}

Expand Down Expand Up @@ -860,7 +862,7 @@ public static CleverTapAPI instanceWithConfig(Context context, @NonNull CleverTa
return null;
}
if (instances == null) {
instances = new HashMap<>();
instances = new ConcurrentHashMap<>();
}

CleverTapAPI instance = instances.get(config.getAccountId());
Expand Down Expand Up @@ -1637,25 +1639,34 @@ public void setInAppNotificationListener(InAppNotificationListener inAppNotifica
}

/**
* Returns the PushPermissionNotificationResponseListener object
* This method unregisters the given instance of the PushPermissionResponseListener if
* previously registered.
* <p>
* Use this method to stop observing the push permission result.
*
* @return An {@link PushPermissionResponseListener} object
* @param pushPermissionResponseListener An {@link PushPermissionResponseListener} object
*/
@SuppressWarnings({"unused", "WeakerAccess"})
public PushPermissionResponseListener getPushPermissionNotificationResponseListener() {
return coreState.getCallbackManager().getPushPermissionResponseListener();
@SuppressWarnings({"unused"})
public void unregisterPushPermissionNotificationResponseListener(PushPermissionResponseListener
pushPermissionResponseListener) {
coreState.getCallbackManager().
unregisterPushPermissionResponseListener(pushPermissionResponseListener);
}

/**
* This method sets the PushPermissionNotificationResponseListener
* This method registers the PushPermissionNotificationResponseListener.
* <p>
* Call this method only from the onCreate() of the activity/fragment and unregister the
* listener from the onDestroy() method using the
* {@link #unregisterPushPermissionNotificationResponseListener(PushPermissionResponseListener)}
*
* @param pushPermissionResponseListener An {@link PushPermissionResponseListener} object
*/
@SuppressWarnings({"unused"})
public void setPushPermissionNotificationResponseListener(PushPermissionResponseListener
public void registerPushPermissionNotificationResponseListener(PushPermissionResponseListener
pushPermissionResponseListener) {
coreState.getCallbackManager().
setPushPermissionResponseListener(pushPermissionResponseListener);
registerPushPermissionResponseListener(pushPermissionResponseListener);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import androidx.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;

@RestrictTo(RestrictTo.Scope.LIBRARY)
public interface Constants {
Expand Down Expand Up @@ -49,7 +47,6 @@ public interface Constants {
int SESSION_LENGTH_MINS = 20;
String DEVICE_ID_TAG = "deviceId";
String FALLBACK_ID_TAG = "fallbackId";
SimpleDateFormat FB_DOB_DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
int PAGE_EVENT = 1;
int PING_EVENT = 2;
int PROFILE_EVENT = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ public void checkPendingInAppNotifications(Activity activity) {

@RequiresApi(api = 33)
public void promptPushPrimer(JSONObject jsonObject){
PushPermissionResponseListener listener = callbackManager.
getPushPermissionResponseListener();
int permissionStatus = ContextCompat.checkSelfPermission(context,
Manifest.permission.POST_NOTIFICATIONS);

Expand All @@ -210,20 +208,15 @@ public void promptPushPrimer(JSONObject jsonObject){
if (!jsonObject.optBoolean(FALLBACK_TO_NOTIFICATION_SETTINGS, false)) {
Logger.v("Notification permission is denied. Please grant notification permission access" +
" in your app's settings to send notifications");
if (listener != null) {
listener.onPushPermissionResponse(false);
}
notifyPushPermissionResult(false);
} else {
showSoftOrHardPrompt(jsonObject);
}
return;
}
showSoftOrHardPrompt(jsonObject);
} else {
//Notification permission is granted
if (listener != null) {
listener.onPushPermissionResponse(true);
}
notifyPushPermissionResult(true);
}
}

Expand Down Expand Up @@ -377,17 +370,20 @@ public void run() {

@Override
public void onPushPermissionAccept() {
final PushPermissionResponseListener listener = callbackManager.getPushPermissionResponseListener();
if (listener != null){
listener.onPushPermissionResponse(true);
}
notifyPushPermissionResult(true);
}

@Override
public void onPushPermissionDeny() {
final PushPermissionResponseListener listener = callbackManager.getPushPermissionResponseListener();
if (listener != null){
listener.onPushPermissionResponse(false);
notifyPushPermissionResult(false);
}

//iterates over the PushPermissionResponseListenerList to notify the result
public void notifyPushPermissionResult(boolean result) {
for (final PushPermissionResponseListener listener: callbackManager.getPushPermissionResponseListenerList()) {
if (listener != null){
listener.onPushPermissionResponse(result);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,16 @@ private int getPingFrequency(Context context) {
* Loads all the plugins that are currently supported by the device.
*/
private void init() {

findEnabledPushTypes();

List<CTPushProvider> providers = createProviders();
Task<Void> task = CTExecutorFactory.executors(config).postAsyncSafelyTask();

findCTPushProviders(providers);
task.addOnSuccessListener(unused -> findCustomEnabledPushTypes());
task.execute("asyncFindCTPushProviders", () -> {
findCTPushProviders(providers);
return null;
});

findCustomEnabledPushTypes();
}

private void initPushAmp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ class ActivityLifeCycleManagerTest : BaseTestCase() {
//`when`(coreState.callbackManager.geofenceCallback).thenReturn(geofenceCallback)

mockStatic(CTExecutorFactory::class.java).use {
`when`(CTExecutorFactory.executors(any())).thenReturn(
MockCTExecutors(
cleverTapInstanceConfig
)
)
`when`(CTExecutorFactory.executors(cleverTapInstanceConfig)).thenReturn(MockCTExecutors(cleverTapInstanceConfig))
mockStatic(InstallReferrerClient::class.java).use {
val referrerDetails = mock(ReferrerDetails::class.java)
val captor = ArgumentCaptor.forClass(InstallReferrerStateListener::class.java)
Expand Down
Loading

0 comments on commit 5bc210d

Please sign in to comment.