clevertap-react-native 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/android/build.gradle +3 -3
- package/android/gradle/wrapper/gradle-wrapper.properties +3 -3
- package/android/gradlew +0 -0
- package/android/src/main/java/com/clevertap/react/CleverTapCustomTemplates.kt +66 -0
- package/android/src/main/java/com/clevertap/react/CleverTapEvent.kt +9 -2
- package/android/src/main/java/com/clevertap/react/CleverTapModuleImpl.java +180 -0
- package/android/src/main/java/com/clevertap/react/CleverTapUtils.java +5 -7
- package/android/src/newarch/CleverTapModule.kt +92 -0
- package/android/src/oldarch/CleverTapModule.kt +108 -2
- package/clevertap-react-native.podspec +1 -1
- package/docs/CustomCodeTemplates.md +215 -0
- package/docs/Variables.md +55 -0
- package/docs/integration.md +42 -46
- package/ios/CleverTapReact/CleverTapReact.h +8 -1
- package/ios/CleverTapReact/CleverTapReact.mm +208 -23
- package/ios/CleverTapReact/CleverTapReactAppFunctionPresenter.h +20 -0
- package/ios/CleverTapReact/CleverTapReactAppFunctionPresenter.mm +21 -0
- package/ios/CleverTapReact/CleverTapReactCustomTemplates.h +42 -0
- package/ios/CleverTapReact/CleverTapReactCustomTemplates.mm +51 -0
- package/ios/CleverTapReact/CleverTapReactManager.h +0 -1
- package/ios/CleverTapReact/CleverTapReactManager.mm +0 -17
- package/ios/CleverTapReact/CleverTapReactTemplatePresenter.h +22 -0
- package/ios/CleverTapReact/CleverTapReactTemplatePresenter.mm +21 -0
- package/ios/CleverTapReact.xcodeproj/project.pbxproj +24 -0
- package/package.json +3 -3
- package/src/NativeCleverTapModule.ts +24 -1
- package/src/index.d.ts +150 -10
- package/src/index.js +187 -3
- package/android/.gradle/8.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.2/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.2/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/8.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/config.properties +0 -2
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
- package/android/local.properties +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
Change Log
|
|
2
2
|
==========
|
|
3
3
|
|
|
4
|
+
Version 3.1.1 *(6 November 2024)*
|
|
5
|
+
-------------------------------------------
|
|
6
|
+
**Bug Fixes**
|
|
7
|
+
|
|
8
|
+
* **[iOS Platform]**
|
|
9
|
+
* Fixes a bug where the push notification callback was getting triggered twice in killed state.
|
|
10
|
+
|
|
11
|
+
Version 3.1.0 *(25 October 2024)*
|
|
12
|
+
-------------------------------------------
|
|
13
|
+
**What's new**
|
|
14
|
+
|
|
15
|
+
* **[Android Platform]**
|
|
16
|
+
* Supports [CleverTap Android SDK v7.0.2](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-702-october-10-2024).
|
|
17
|
+
* Adds support for custom handshake domain configuration in android manifest
|
|
18
|
+
|
|
19
|
+
* **[iOS Platform]**
|
|
20
|
+
* Supports [CleverTap iOS SDK v7.0.2](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-702-october-10-2024).
|
|
21
|
+
* Adds support for custom handshake domains.
|
|
22
|
+
|
|
23
|
+
* **[Android and iOS Platform]**
|
|
24
|
+
* Adds support for File Type Variables in Remote Config. Please refer to the [Remote Config Variables](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/docs/Variables.md) doc to read more on how to integrate this in your app.
|
|
25
|
+
* Adds support for Custom Code Templates. Please refer to the [CustomCodeTemplates.md](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CustomCodeTemplates.md) doc to read more on how to integrate this in your app.
|
|
26
|
+
* Adds support for custom code in-app templates definitions through a json scheme.
|
|
27
|
+
|
|
28
|
+
**Bug Fixes**
|
|
29
|
+
* **[Android and iOS Platform]**
|
|
30
|
+
* Fixes a missing import statement in the index.js file https://github.com/CleverTap/clevertap-react-native/issues/431
|
|
31
|
+
* Fixes https://github.com/CleverTap/clevertap-react-native/issues/426
|
|
32
|
+
|
|
4
33
|
Version 3.0.0 *(8 October 2024)*
|
|
5
34
|
-------------------------------------------
|
|
6
35
|
**What's new**
|
package/android/build.gradle
CHANGED
|
@@ -35,8 +35,8 @@ android {
|
|
|
35
35
|
defaultConfig {
|
|
36
36
|
minSdkVersion 19
|
|
37
37
|
targetSdkVersion 34
|
|
38
|
-
versionCode
|
|
39
|
-
versionName "3.
|
|
38
|
+
versionCode 311
|
|
39
|
+
versionName "3.1.1"
|
|
40
40
|
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -54,7 +54,7 @@ android {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
dependencies {
|
|
57
|
-
api 'com.clevertap.android:clevertap-android-sdk:7.0.
|
|
57
|
+
api 'com.clevertap.android:clevertap-android-sdk:7.0.2'
|
|
58
58
|
implementation 'com.android.installreferrer:installreferrer:2.2'
|
|
59
59
|
//compile 'com.android.support:appcompat-v7:28.0.0'
|
|
60
60
|
implementation 'com.facebook.react:react-native:+'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
#Thu Oct 17 18:09:17 IST 2024
|
|
2
2
|
distributionBase=GRADLE_USER_HOME
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
|
|
4
3
|
distributionPath=wrapper/dists
|
|
5
|
-
|
|
4
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
|
6
5
|
zipStoreBase=GRADLE_USER_HOME
|
|
6
|
+
zipStorePath=wrapper/dists
|
package/android/gradlew
CHANGED
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package com.clevertap.react
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.clevertap.android.sdk.CleverTapAPI
|
|
5
|
+
import com.clevertap.android.sdk.inapp.customtemplates.CustomTemplateContext.FunctionContext
|
|
6
|
+
import com.clevertap.android.sdk.inapp.customtemplates.CustomTemplateContext.TemplateContext
|
|
7
|
+
import com.clevertap.android.sdk.inapp.customtemplates.CustomTemplateException
|
|
8
|
+
import com.clevertap.android.sdk.inapp.customtemplates.FunctionPresenter
|
|
9
|
+
import com.clevertap.android.sdk.inapp.customtemplates.TemplatePresenter
|
|
10
|
+
import java.io.BufferedReader
|
|
11
|
+
import java.io.IOException
|
|
12
|
+
import java.io.InputStreamReader
|
|
13
|
+
import java.nio.charset.StandardCharsets
|
|
14
|
+
|
|
15
|
+
object CleverTapCustomTemplates {
|
|
16
|
+
|
|
17
|
+
private val templatePresenter: TemplatePresenter = object : TemplatePresenter {
|
|
18
|
+
override fun onPresent(context: TemplateContext) {
|
|
19
|
+
CleverTapEventEmitter.emit(
|
|
20
|
+
CleverTapEvent.CLEVERTAP_CUSTOM_TEMPLATE_PRESENT, context.templateName
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun onClose(context: TemplateContext) {
|
|
25
|
+
CleverTapEventEmitter.emit(
|
|
26
|
+
CleverTapEvent.CLEVERTAP_CUSTOM_TEMPLATE_CLOSE, context.templateName
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private val functionPresenter = FunctionPresenter { context: FunctionContext ->
|
|
32
|
+
CleverTapEventEmitter.emit(
|
|
33
|
+
CleverTapEvent.CLEVERTAP_CUSTOM_FUNCTION_PRESENT, context.templateName
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@JvmStatic
|
|
38
|
+
fun registerCustomTemplates(context: Context, vararg jsonAssets: String) {
|
|
39
|
+
for (jsonAsset in jsonAssets) {
|
|
40
|
+
val jsonDefinitions = readAsset(context, jsonAsset)
|
|
41
|
+
CleverTapAPI.registerCustomInAppTemplates(
|
|
42
|
+
jsonDefinitions, templatePresenter, functionPresenter
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private fun readAsset(context: Context, asset: String): String {
|
|
48
|
+
val assetManager = context.assets
|
|
49
|
+
try {
|
|
50
|
+
assetManager.open(asset).use { assetInputStream ->
|
|
51
|
+
val reader =
|
|
52
|
+
BufferedReader(InputStreamReader(assetInputStream, StandardCharsets.UTF_8))
|
|
53
|
+
|
|
54
|
+
return buildString {
|
|
55
|
+
var line = reader.readLine()
|
|
56
|
+
while (line != null) {
|
|
57
|
+
append(line)
|
|
58
|
+
line = reader.readLine()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch (e: IOException) {
|
|
63
|
+
throw CustomTemplateException("Could not read json asset", e)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -12,14 +12,21 @@ enum class CleverTapEvent(val eventName: String, val bufferable: Boolean = false
|
|
|
12
12
|
CLEVERTAP_ON_INBOX_MESSAGE_CLICK("CleverTapInboxMessageTapped"),
|
|
13
13
|
CLEVERTAP_ON_INAPP_BUTTON_CLICK("CleverTapInAppNotificationButtonTapped", bufferable = true),
|
|
14
14
|
CLEVERTAP_ON_DISPLAY_UNITS_LOADED("CleverTapDisplayUnitsLoaded", bufferable = true),
|
|
15
|
-
CLEVERTAP_FEATURE_FLAGS_DID_UPDATE("CleverTapFeatureFlagsDidUpdate"),
|
|
15
|
+
CLEVERTAP_FEATURE_FLAGS_DID_UPDATE("CleverTapFeatureFlagsDidUpdate", bufferable = true),
|
|
16
16
|
CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE("CleverTapProductConfigDidInitialize", bufferable = true),
|
|
17
17
|
CLEVERTAP_PRODUCT_CONFIG_DID_FETCH("CleverTapProductConfigDidFetch"),
|
|
18
18
|
CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE("CleverTapProductConfigDidActivate"),
|
|
19
19
|
CLEVERTAP_PUSH_NOTIFICATION_CLICKED("CleverTapPushNotificationClicked", bufferable = true),
|
|
20
20
|
CLEVERTAP_ON_PUSH_PERMISSION_RESPONSE("CleverTapPushPermissionResponseReceived"),
|
|
21
21
|
CLEVERTAP_ON_VARIABLES_CHANGED("CleverTapOnVariablesChanged"),
|
|
22
|
-
|
|
22
|
+
CLEVERTAP_ON_ONE_TIME_VARIABLES_CHANGED("CleverTapOnOneTimeVariablesChanged"),
|
|
23
|
+
CLEVERTAP_ON_VALUE_CHANGED("CleverTapOnValueChanged"),
|
|
24
|
+
CLEVERTAP_CUSTOM_TEMPLATE_PRESENT("CleverTapCustomTemplatePresent", bufferable = true),
|
|
25
|
+
CLEVERTAP_CUSTOM_FUNCTION_PRESENT("CleverTapCustomFunctionPresent", bufferable = true),
|
|
26
|
+
CLEVERTAP_CUSTOM_TEMPLATE_CLOSE("CleverTapCustomTemplateClose"),
|
|
27
|
+
CLEVERTAP_ON_FILE_VALUE_CHANGED("CleverTapOnFileValueChanged"),
|
|
28
|
+
CLEVERTAP_ON_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING("CleverTapOnVariablesChangedAndNoDownloadsPending"),
|
|
29
|
+
CLEVERTAP_ONCE_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING("CleverTapOnceVariablesChangedAndNoDownloadsPending");
|
|
23
30
|
|
|
24
31
|
override fun toString(): String {
|
|
25
32
|
return eventName
|
|
@@ -28,6 +28,7 @@ import com.clevertap.android.sdk.events.EventDetail;
|
|
|
28
28
|
import com.clevertap.android.sdk.featureFlags.CTFeatureFlagsController;
|
|
29
29
|
import com.clevertap.android.sdk.inapp.CTLocalInApp;
|
|
30
30
|
import com.clevertap.android.sdk.inapp.callbacks.FetchInAppsCallback;
|
|
31
|
+
import com.clevertap.android.sdk.inapp.customtemplates.CustomTemplateContext;
|
|
31
32
|
import com.clevertap.android.sdk.inbox.CTInboxMessage;
|
|
32
33
|
import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
|
|
33
34
|
import com.clevertap.android.sdk.product_config.CTProductConfigController;
|
|
@@ -38,6 +39,7 @@ import com.clevertap.android.sdk.variables.callbacks.VariableCallback;
|
|
|
38
39
|
import com.clevertap.android.sdk.variables.callbacks.VariablesChangedCallback;
|
|
39
40
|
import com.facebook.react.bridge.Arguments;
|
|
40
41
|
import com.facebook.react.bridge.Callback;
|
|
42
|
+
import com.facebook.react.bridge.Promise;
|
|
41
43
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
42
44
|
import com.facebook.react.bridge.ReactContext;
|
|
43
45
|
import com.facebook.react.bridge.ReadableArray;
|
|
@@ -1066,6 +1068,114 @@ public class CleverTapModuleImpl {
|
|
|
1066
1068
|
}
|
|
1067
1069
|
}
|
|
1068
1070
|
|
|
1071
|
+
public void customTemplateSetDismissed(String templateName, Promise promise) {
|
|
1072
|
+
resolveWithTemplateContext(templateName, promise, templateContext -> {
|
|
1073
|
+
templateContext.setDismissed();
|
|
1074
|
+
return null;
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
public void customTemplateSetPresented(String templateName, Promise promise) {
|
|
1079
|
+
resolveWithTemplateContext(templateName, promise, templateContext -> {
|
|
1080
|
+
templateContext.setPresented();
|
|
1081
|
+
return null;
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
public void customTemplateRunAction(String templateName, String argName, Promise promise) {
|
|
1086
|
+
resolveWithTemplateContext(
|
|
1087
|
+
templateName,
|
|
1088
|
+
promise,
|
|
1089
|
+
customTemplateContext -> {
|
|
1090
|
+
if (customTemplateContext instanceof CustomTemplateContext.TemplateContext) {
|
|
1091
|
+
((CustomTemplateContext.TemplateContext) customTemplateContext).triggerActionArgument(argName, null);
|
|
1092
|
+
}
|
|
1093
|
+
return null;
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
public void customTemplateGetStringArg(String templateName, String argName, Promise promise) {
|
|
1099
|
+
resolveWithTemplateContext(
|
|
1100
|
+
templateName,
|
|
1101
|
+
promise,
|
|
1102
|
+
templateContext -> templateContext.getString(argName)
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
public void customTemplateGetNumberArg(String templateName, String argName, Promise promise) {
|
|
1107
|
+
resolveWithTemplateContext(
|
|
1108
|
+
templateName,
|
|
1109
|
+
promise,
|
|
1110
|
+
templateContext -> templateContext.getDouble(argName)
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
public void customTemplateGetBooleanArg(String templateName, String argName, Promise promise) {
|
|
1115
|
+
resolveWithTemplateContext(
|
|
1116
|
+
templateName,
|
|
1117
|
+
promise,
|
|
1118
|
+
templateContext -> templateContext.getBoolean(argName)
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
public void customTemplateGetFileArg(String templateName, String argName, Promise promise) {
|
|
1123
|
+
resolveWithTemplateContext(
|
|
1124
|
+
templateName,
|
|
1125
|
+
promise,
|
|
1126
|
+
templateContext -> templateContext.getFile(argName)
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
public void customTemplateGetObjectArg(String templateName, String argName, Promise promise) {
|
|
1131
|
+
resolveWithTemplateContext(
|
|
1132
|
+
templateName,
|
|
1133
|
+
promise,
|
|
1134
|
+
templateContext -> {
|
|
1135
|
+
Map<String, Object> mapArg = templateContext.getMap(argName);
|
|
1136
|
+
if (mapArg != null) {
|
|
1137
|
+
return CleverTapUtils.MapUtil.toWritableMap(mapArg);
|
|
1138
|
+
} else {
|
|
1139
|
+
return null;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
);
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
public void customTemplateContextToString(String templateName, Promise promise) {
|
|
1146
|
+
resolveWithTemplateContext(
|
|
1147
|
+
templateName,
|
|
1148
|
+
promise,
|
|
1149
|
+
templateContext -> templateContext.toString()
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
public void syncCustomTemplates() {
|
|
1154
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1155
|
+
if (cleverTap != null) {
|
|
1156
|
+
cleverTap.syncRegisteredInAppTemplates();
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
private void resolveWithTemplateContext(String templateName, Promise promise, TemplateContextAction action) {
|
|
1161
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1162
|
+
if (cleverTap != null) {
|
|
1163
|
+
CustomTemplateContext templateContext = cleverTap.getActiveContextForTemplate(templateName);
|
|
1164
|
+
if (templateContext != null) {
|
|
1165
|
+
promise.resolve(action.execute(templateContext));
|
|
1166
|
+
} else {
|
|
1167
|
+
promise.reject("CustomTemplateError", "Custom template: " + templateName + " is not currently being presented");
|
|
1168
|
+
}
|
|
1169
|
+
} else {
|
|
1170
|
+
promise.reject("CustomTemplateError", "CleverTap is not initialized");
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
@FunctionalInterface
|
|
1175
|
+
private interface TemplateContextAction {
|
|
1176
|
+
Object execute(CustomTemplateContext context);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1069
1179
|
/**************************************************
|
|
1070
1180
|
* Product Experience Remote Config methods starts
|
|
1071
1181
|
*************************************************/
|
|
@@ -1098,6 +1208,13 @@ public class CleverTapModuleImpl {
|
|
|
1098
1208
|
}
|
|
1099
1209
|
}
|
|
1100
1210
|
|
|
1211
|
+
public void defineFileVariable(String name) {
|
|
1212
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1213
|
+
if (cleverTap != null) {
|
|
1214
|
+
variables.put(name, cleverTap.defineFileVariable(name));
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1101
1218
|
public void fetchVariables(final Callback callback) {
|
|
1102
1219
|
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1103
1220
|
if (cleverTap != null) {
|
|
@@ -1158,6 +1275,31 @@ public class CleverTapModuleImpl {
|
|
|
1158
1275
|
}
|
|
1159
1276
|
}
|
|
1160
1277
|
|
|
1278
|
+
public void onFileValueChanged(final String name) {
|
|
1279
|
+
if (variables.containsKey(name)) {
|
|
1280
|
+
|
|
1281
|
+
Var<Object> var = (Var<Object>) variables.get(name);
|
|
1282
|
+
if (var != null) {
|
|
1283
|
+
var.addFileReadyHandler(new VariableCallback<Object>() {
|
|
1284
|
+
@Override
|
|
1285
|
+
public void onValueChanged(final Var<Object> variable) {
|
|
1286
|
+
WritableMap result = null;
|
|
1287
|
+
try {
|
|
1288
|
+
result = getVariableValueAsWritableMap(name);
|
|
1289
|
+
} catch (IllegalArgumentException e) {
|
|
1290
|
+
Log.e(TAG, e.getLocalizedMessage());
|
|
1291
|
+
}
|
|
1292
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_FILE_VALUE_CHANGED, result);
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
} else {
|
|
1296
|
+
Log.d(TAG, "File variable object with name = " + name + " contains null value. Not setting onFileValueChanged callback.");
|
|
1297
|
+
}
|
|
1298
|
+
} else {
|
|
1299
|
+
Log.e(TAG, "File variable name = " + name + " does not exist. Make sure you set file variable first.");
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1161
1303
|
public void onVariablesChanged() {
|
|
1162
1304
|
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1163
1305
|
if (cleverTap != null) {
|
|
@@ -1170,6 +1312,44 @@ public class CleverTapModuleImpl {
|
|
|
1170
1312
|
}
|
|
1171
1313
|
}
|
|
1172
1314
|
|
|
1315
|
+
public void onOneTimeVariablesChanged() {
|
|
1316
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1317
|
+
if (cleverTap != null) {
|
|
1318
|
+
cleverTap.addOneTimeVariablesChangedCallback(new VariablesChangedCallback() {
|
|
1319
|
+
@Override
|
|
1320
|
+
public void variablesChanged() {
|
|
1321
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_ONE_TIME_VARIABLES_CHANGED, getVariablesValues());
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
public void onVariablesChangedAndNoDownloadsPending() {
|
|
1328
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1329
|
+
if (cleverTap != null) {
|
|
1330
|
+
cleverTap.onVariablesChangedAndNoDownloadsPending(new VariablesChangedCallback() {
|
|
1331
|
+
@Override
|
|
1332
|
+
public void variablesChanged() {
|
|
1333
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING,
|
|
1334
|
+
getVariablesValues());
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
public void onceVariablesChangedAndNoDownloadsPending() {
|
|
1341
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1342
|
+
if (cleverTap != null) {
|
|
1343
|
+
cleverTap.onceVariablesChangedAndNoDownloadsPending(new VariablesChangedCallback() {
|
|
1344
|
+
@Override
|
|
1345
|
+
public void variablesChanged() {
|
|
1346
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ONCE_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING,
|
|
1347
|
+
getVariablesValues());
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1173
1353
|
/************************************************
|
|
1174
1354
|
* Product Experience Remote Config methods ends
|
|
1175
1355
|
************************************************/
|
|
@@ -7,25 +7,23 @@ import androidx.annotation.Nullable;
|
|
|
7
7
|
|
|
8
8
|
import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
|
|
9
9
|
import com.facebook.react.bridge.Arguments;
|
|
10
|
-
import com.facebook.react.bridge.WritableArray;
|
|
11
10
|
import com.facebook.react.bridge.ReadableArray;
|
|
12
11
|
import com.facebook.react.bridge.ReadableMap;
|
|
13
12
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
14
13
|
import com.facebook.react.bridge.ReadableType;
|
|
15
14
|
import com.facebook.react.bridge.WritableArray;
|
|
16
15
|
import com.facebook.react.bridge.WritableMap;
|
|
16
|
+
|
|
17
|
+
import org.json.JSONArray;
|
|
18
|
+
import org.json.JSONException;
|
|
19
|
+
import org.json.JSONObject;
|
|
20
|
+
|
|
17
21
|
import java.util.ArrayList;
|
|
18
22
|
import java.util.HashMap;
|
|
19
23
|
import java.util.Iterator;
|
|
20
24
|
import java.util.List;
|
|
21
25
|
import java.util.Map;
|
|
22
26
|
|
|
23
|
-
import org.json.JSONArray;
|
|
24
|
-
import org.json.JSONException;
|
|
25
|
-
import org.json.JSONArray;
|
|
26
|
-
import org.json.JSONException;
|
|
27
|
-
import org.json.JSONObject;
|
|
28
|
-
|
|
29
27
|
public class CleverTapUtils {
|
|
30
28
|
|
|
31
29
|
private static final String TAG = "CleverTapUtils";
|
|
@@ -5,6 +5,7 @@ import android.os.Build.VERSION_CODES
|
|
|
5
5
|
import androidx.annotation.RequiresApi
|
|
6
6
|
import com.clevertap.android.sdk.CleverTapAPI
|
|
7
7
|
import com.facebook.react.bridge.Callback
|
|
8
|
+
import com.facebook.react.bridge.Promise
|
|
8
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
10
|
import com.facebook.react.bridge.ReadableArray
|
|
10
11
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -443,6 +444,77 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
|
|
|
443
444
|
cleverTapModuleImpl.clearInAppResources(expiredOnly)
|
|
444
445
|
}
|
|
445
446
|
|
|
447
|
+
override fun customTemplateSetDismissed(templateName: String?, promise: Promise?) {
|
|
448
|
+
cleverTapModuleImpl.customTemplateSetDismissed(templateName, promise)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
override fun customTemplateSetPresented(templateName: String?, promise: Promise?) {
|
|
452
|
+
cleverTapModuleImpl.customTemplateSetPresented(templateName, promise)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
override fun customTemplateRunAction(
|
|
456
|
+
templateName: String?,
|
|
457
|
+
argName: String?,
|
|
458
|
+
promise: Promise?
|
|
459
|
+
) {
|
|
460
|
+
cleverTapModuleImpl.customTemplateRunAction(templateName, argName, promise)
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
override fun customTemplateGetStringArg(
|
|
464
|
+
templateName: String?,
|
|
465
|
+
argName: String?,
|
|
466
|
+
promise: Promise?
|
|
467
|
+
) {
|
|
468
|
+
cleverTapModuleImpl.customTemplateGetStringArg(templateName, argName, promise)
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
override fun customTemplateGetNumberArg(
|
|
472
|
+
templateName: String?,
|
|
473
|
+
argName: String?,
|
|
474
|
+
promise: Promise?
|
|
475
|
+
) {
|
|
476
|
+
cleverTapModuleImpl.customTemplateGetNumberArg(templateName, argName, promise)
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
override fun customTemplateGetBooleanArg(
|
|
480
|
+
templateName: String?,
|
|
481
|
+
argName: String?,
|
|
482
|
+
promise: Promise?
|
|
483
|
+
) {
|
|
484
|
+
cleverTapModuleImpl.customTemplateGetBooleanArg(templateName, argName, promise)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
override fun customTemplateGetFileArg(
|
|
488
|
+
templateName: String?,
|
|
489
|
+
argName: String?,
|
|
490
|
+
promise: Promise?
|
|
491
|
+
) {
|
|
492
|
+
cleverTapModuleImpl.customTemplateGetFileArg(templateName, argName, promise)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
override fun customTemplateGetObjectArg(
|
|
496
|
+
templateName: String?,
|
|
497
|
+
argName: String?,
|
|
498
|
+
promise: Promise?
|
|
499
|
+
) {
|
|
500
|
+
cleverTapModuleImpl.customTemplateGetObjectArg(templateName, argName, promise)
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
override fun customTemplateContextToString(
|
|
504
|
+
templateName: String?,
|
|
505
|
+
promise: Promise?
|
|
506
|
+
) {
|
|
507
|
+
cleverTapModuleImpl.customTemplateContextToString(templateName, promise)
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
override fun syncCustomTemplates() {
|
|
511
|
+
cleverTapModuleImpl.syncCustomTemplates()
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
override fun syncCustomTemplatesInProd(isProduction: Boolean) {
|
|
515
|
+
cleverTapModuleImpl.syncCustomTemplates()
|
|
516
|
+
}
|
|
517
|
+
|
|
446
518
|
override fun syncVariables() {
|
|
447
519
|
cleverTapModuleImpl.syncVariables()
|
|
448
520
|
}
|
|
@@ -455,6 +527,10 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
|
|
|
455
527
|
cleverTapModuleImpl.defineVariables(`object`)
|
|
456
528
|
}
|
|
457
529
|
|
|
530
|
+
override fun defineFileVariable(name: String) {
|
|
531
|
+
cleverTapModuleImpl.defineFileVariable(name)
|
|
532
|
+
}
|
|
533
|
+
|
|
458
534
|
override fun fetchVariables(callback: Callback?) {
|
|
459
535
|
cleverTapModuleImpl.fetchVariables(callback)
|
|
460
536
|
}
|
|
@@ -471,10 +547,26 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
|
|
|
471
547
|
cleverTapModuleImpl.onVariablesChanged()
|
|
472
548
|
}
|
|
473
549
|
|
|
550
|
+
override fun onOneTimeVariablesChanged() {
|
|
551
|
+
cleverTapModuleImpl.onOneTimeVariablesChanged()
|
|
552
|
+
}
|
|
553
|
+
|
|
474
554
|
override fun onValueChanged(name: String) {
|
|
475
555
|
cleverTapModuleImpl.onValueChanged(name)
|
|
476
556
|
}
|
|
477
557
|
|
|
558
|
+
override fun onFileValueChanged(name: String) {
|
|
559
|
+
cleverTapModuleImpl.onFileValueChanged(name)
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
override fun onVariablesChangedAndNoDownloadsPending() {
|
|
563
|
+
cleverTapModuleImpl.onVariablesChangedAndNoDownloadsPending()
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
override fun onceVariablesChangedAndNoDownloadsPending() {
|
|
567
|
+
cleverTapModuleImpl.onceVariablesChangedAndNoDownloadsPending()
|
|
568
|
+
}
|
|
569
|
+
|
|
478
570
|
override fun onEventListenerAdded(eventName: String) {
|
|
479
571
|
cleverTapModuleImpl.onEventListenerAdded(eventName)
|
|
480
572
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
package com.clevertap.react
|
|
2
2
|
|
|
3
|
-
import android.annotation.SuppressLint
|
|
4
3
|
import android.net.Uri
|
|
5
4
|
import android.os.Build.VERSION_CODES
|
|
6
5
|
import androidx.annotation.RequiresApi
|
|
7
6
|
import com.clevertap.android.sdk.CleverTapAPI
|
|
8
7
|
import com.facebook.react.bridge.Callback
|
|
8
|
+
import com.facebook.react.bridge.Promise
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
10
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
11
11
|
import com.facebook.react.bridge.ReactMethod
|
|
@@ -37,7 +37,6 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
|
|
|
37
37
|
return Constants.REACT_MODULE_NAME
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
@SuppressLint("RestrictedApi")
|
|
41
40
|
@ReactMethod
|
|
42
41
|
fun setLibrary(libName: String?, libVersion: Int) {
|
|
43
42
|
cleverTapModuleImpl.setLibrary(libName, libVersion)
|
|
@@ -524,6 +523,88 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
|
|
|
524
523
|
cleverTapModuleImpl.clearInAppResources(expiredOnly)
|
|
525
524
|
}
|
|
526
525
|
|
|
526
|
+
@ReactMethod
|
|
527
|
+
fun customTemplateSetDismissed(templateName: String?, promise: Promise?) {
|
|
528
|
+
cleverTapModuleImpl.customTemplateSetDismissed(templateName, promise)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
@ReactMethod
|
|
532
|
+
fun customTemplateSetPresented(templateName: String?, promise: Promise?) {
|
|
533
|
+
cleverTapModuleImpl.customTemplateSetPresented(templateName, promise)
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
@ReactMethod
|
|
537
|
+
fun customTemplateRunAction(
|
|
538
|
+
templateName: String?,
|
|
539
|
+
argName: String?,
|
|
540
|
+
promise: Promise?
|
|
541
|
+
) {
|
|
542
|
+
cleverTapModuleImpl.customTemplateRunAction(templateName, argName, promise)
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
@ReactMethod
|
|
546
|
+
fun customTemplateGetStringArg(
|
|
547
|
+
templateName: String?,
|
|
548
|
+
argName: String?,
|
|
549
|
+
promise: Promise?
|
|
550
|
+
) {
|
|
551
|
+
cleverTapModuleImpl.customTemplateGetStringArg(templateName, argName, promise)
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
@ReactMethod
|
|
555
|
+
fun customTemplateGetNumberArg(
|
|
556
|
+
templateName: String?,
|
|
557
|
+
argName: String?,
|
|
558
|
+
promise: Promise?
|
|
559
|
+
) {
|
|
560
|
+
cleverTapModuleImpl.customTemplateGetNumberArg(templateName, argName, promise)
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
@ReactMethod
|
|
564
|
+
fun customTemplateGetBooleanArg(
|
|
565
|
+
templateName: String?,
|
|
566
|
+
argName: String?,
|
|
567
|
+
promise: Promise?
|
|
568
|
+
) {
|
|
569
|
+
cleverTapModuleImpl.customTemplateGetBooleanArg(templateName, argName, promise)
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
@ReactMethod
|
|
573
|
+
fun customTemplateGetFileArg(
|
|
574
|
+
templateName: String?,
|
|
575
|
+
argName: String?,
|
|
576
|
+
promise: Promise?
|
|
577
|
+
) {
|
|
578
|
+
cleverTapModuleImpl.customTemplateGetFileArg(templateName, argName, promise)
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
@ReactMethod
|
|
582
|
+
fun customTemplateGetObjectArg(
|
|
583
|
+
templateName: String?,
|
|
584
|
+
argName: String?,
|
|
585
|
+
promise: Promise?
|
|
586
|
+
) {
|
|
587
|
+
cleverTapModuleImpl.customTemplateGetObjectArg(templateName, argName, promise)
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
@ReactMethod
|
|
591
|
+
fun customTemplateContextToString(
|
|
592
|
+
templateName: String?,
|
|
593
|
+
promise: Promise?
|
|
594
|
+
) {
|
|
595
|
+
cleverTapModuleImpl.customTemplateContextToString(templateName, promise)
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
@ReactMethod
|
|
599
|
+
fun syncCustomTemplates() {
|
|
600
|
+
cleverTapModuleImpl.syncCustomTemplates()
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
@ReactMethod
|
|
604
|
+
fun syncCustomTemplatesInProd(isProduction: Boolean) {
|
|
605
|
+
cleverTapModuleImpl.syncCustomTemplates()
|
|
606
|
+
}
|
|
607
|
+
|
|
527
608
|
@ReactMethod
|
|
528
609
|
fun syncVariables() {
|
|
529
610
|
cleverTapModuleImpl.syncVariables()
|
|
@@ -539,6 +620,11 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
|
|
|
539
620
|
cleverTapModuleImpl.defineVariables(`object`)
|
|
540
621
|
}
|
|
541
622
|
|
|
623
|
+
@ReactMethod
|
|
624
|
+
fun defineFileVariable(name: String) {
|
|
625
|
+
cleverTapModuleImpl.defineFileVariable(name)
|
|
626
|
+
}
|
|
627
|
+
|
|
542
628
|
@ReactMethod
|
|
543
629
|
fun fetchVariables(callback: Callback?) {
|
|
544
630
|
cleverTapModuleImpl.fetchVariables(callback)
|
|
@@ -559,11 +645,31 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
|
|
|
559
645
|
cleverTapModuleImpl.onVariablesChanged()
|
|
560
646
|
}
|
|
561
647
|
|
|
648
|
+
@ReactMethod
|
|
649
|
+
fun onOneTimeVariablesChanged() {
|
|
650
|
+
cleverTapModuleImpl.onOneTimeVariablesChanged()
|
|
651
|
+
}
|
|
652
|
+
|
|
562
653
|
@ReactMethod
|
|
563
654
|
fun onValueChanged(name: String) {
|
|
564
655
|
cleverTapModuleImpl.onValueChanged(name)
|
|
565
656
|
}
|
|
566
657
|
|
|
658
|
+
@ReactMethod
|
|
659
|
+
fun onFileValueChanged(name: String) {
|
|
660
|
+
cleverTapModuleImpl.onFileValueChanged(name)
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
@ReactMethod
|
|
664
|
+
fun onVariablesChangedAndNoDownloadsPending() {
|
|
665
|
+
cleverTapModuleImpl.onVariablesChangedAndNoDownloadsPending()
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
@ReactMethod
|
|
669
|
+
fun onceVariablesChangedAndNoDownloadsPending() {
|
|
670
|
+
cleverTapModuleImpl.onceVariablesChangedAndNoDownloadsPending()
|
|
671
|
+
}
|
|
672
|
+
|
|
567
673
|
@ReactMethod
|
|
568
674
|
fun onEventListenerAdded(eventName: String) {
|
|
569
675
|
cleverTapModuleImpl.onEventListenerAdded(eventName)
|