clevertap-react-native 0.5.0 → 0.7.0

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.
Files changed (117) hide show
  1. package/.codebeatignore +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/LICENSE +2 -2
  4. package/README.md +21 -18
  5. package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/6.1.1/fileContent/fileContent.lock +0 -0
  8. package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/{5.4.1 → 6.1.1}/fileHashes/resourceHashesCache.bin +0 -0
  11. package/android/.gradle/6.1.1/javaCompile/classAnalysis.bin +0 -0
  12. package/android/.gradle/6.1.1/javaCompile/jarAnalysis.bin +0 -0
  13. package/android/.gradle/6.1.1/javaCompile/javaCompile.lock +0 -0
  14. package/android/.gradle/6.1.1/javaCompile/taskHistory.bin +0 -0
  15. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  16. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  17. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  18. package/android/.gradle/checksums/checksums.lock +0 -0
  19. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  20. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  21. package/android/android.iml +24 -18
  22. package/android/build/generated/source/buildConfig/debug/com/clevertap/react/BuildConfig.java +2 -8
  23. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +3 -8
  24. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +27 -1
  25. package/android/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
  26. package/android/build/intermediates/annotations_typedef_file/debug/{extractDebugAnnotations/typedefs.txt → typedefs.txt} +0 -0
  27. package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
  28. package/android/build/intermediates/compile_symbol_list/debug/R.txt +4287 -0
  29. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  30. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +1 -1
  31. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -1
  32. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/BuildConfig.class +0 -0
  33. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$1.class +0 -0
  34. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$ErrorMessages.class +0 -0
  35. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$InBoxMessages.class +0 -0
  36. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule.class +0 -0
  37. package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +3 -8
  38. package/android/build/intermediates/local_only_symbol_list/debug/{parseDebugLibraryResources/R-def.txt → R-def.txt} +0 -0
  39. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +7 -16
  40. package/android/build/intermediates/merged_manifests/debug/output.json +27 -1
  41. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +3208 -0
  42. package/android/build/outputs/aar/android-debug.aar +0 -0
  43. package/android/build/outputs/logs/manifest-merger-debug-report.txt +10 -18
  44. package/android/build.gradle +9 -9
  45. package/android/src/main/java/com/clevertap/react/CleverTapModule.java +827 -1263
  46. package/android/src/main/java/com/clevertap/react/CleverTapPackage.java +1 -1
  47. package/clevertap-react-native.podspec +1 -1
  48. package/docs/install.md +15 -19
  49. package/docs/integration.md +2 -3
  50. package/docs/usage.md +397 -0
  51. package/index.d.ts +60 -224
  52. package/index.js +227 -374
  53. package/ios/CleverTapReact/CleverTapReact.h +0 -1
  54. package/ios/CleverTapReact/CleverTapReact.m +33 -147
  55. package/ios/CleverTapReact/CleverTapReactEventEmitter.m +1 -6
  56. package/ios/CleverTapReact/CleverTapReactManager.m +0 -4
  57. package/ios/CleverTapReact/CleverTapSDK.framework.zip +0 -0
  58. package/package.json +1 -1
  59. package/.idea/clevertap-rn.iml +0 -9
  60. package/.idea/codeStyles/Project.xml +0 -134
  61. package/.idea/modules.xml +0 -8
  62. package/.idea/vcs.xml +0 -6
  63. package/.idea/workspace.xml +0 -449
  64. package/android/.gradle/5.4.1/executionHistory/executionHistory.bin +0 -0
  65. package/android/.gradle/5.4.1/executionHistory/executionHistory.lock +0 -0
  66. package/android/.gradle/5.4.1/fileChanges/last-build.bin +0 -0
  67. package/android/.gradle/5.4.1/fileContent/fileContent.lock +0 -0
  68. package/android/.gradle/5.4.1/fileHashes/fileHashes.bin +0 -0
  69. package/android/.gradle/5.4.1/fileHashes/fileHashes.lock +0 -0
  70. package/android/.gradle/5.4.1/gc.properties +0 -0
  71. package/android/.gradle/5.4.1/javaCompile/classAnalysis.bin +0 -0
  72. package/android/.gradle/5.4.1/javaCompile/jarAnalysis.bin +0 -0
  73. package/android/.gradle/5.4.1/javaCompile/javaCompile.lock +0 -0
  74. package/android/.gradle/5.4.1/javaCompile/taskHistory.bin +0 -0
  75. package/android/.idea/caches/build_file_checksums.ser +0 -0
  76. package/android/.idea/caches/gradle_models.ser +0 -0
  77. package/android/.idea/codeStyles/Project.xml +0 -134
  78. package/android/.idea/dictionaries/piyush_kukadiya.xml +0 -7
  79. package/android/.idea/gradle.xml +0 -20
  80. package/android/.idea/jarRepositories.xml +0 -40
  81. package/android/.idea/libraries/Gradle__com_android_installreferrer_installreferrer_2_1_aar.xml +0 -11
  82. package/android/.idea/libraries/Gradle__com_android_support_appcompat_v7_23_0_1_aar.xml +0 -18
  83. package/android/.idea/libraries/Gradle__com_android_support_support_annotations_23_0_1_jar.xml +0 -13
  84. package/android/.idea/libraries/Gradle__com_android_support_support_v4_23_0_1_aar.xml +0 -19
  85. package/android/.idea/libraries/Gradle__com_clevertap_android_clevertap_android_sdk_4_0_0_aar.xml +0 -16
  86. package/android/.idea/libraries/Gradle__com_facebook_fbui_textlayoutbuilder_staticlayout_proxy_1_0_jar.xml +0 -13
  87. package/android/.idea/libraries/Gradle__com_facebook_fbui_textlayoutbuilder_textlayoutbuilder_1_0_0_aar.xml +0 -18
  88. package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_1_3_0_aar.xml +0 -15
  89. package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_1_3_0_aar.xml +0 -18
  90. package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_1_3_0_aar.xml +0 -15
  91. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_1_3_0_aar.xml +0 -18
  92. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_1_3_0_aar.xml +0 -18
  93. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_1_3_0_aar.xml +0 -15
  94. package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_49_5_aar.xml +0 -19
  95. package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_1_0_aar.xml +0 -15
  96. package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_0_jar.xml +0 -13
  97. package/android/.idea/libraries/Gradle__com_parse_bolts_bolts_tasks_1_4_0_jar.xml +0 -13
  98. package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_6_0_jar.xml +0 -13
  99. package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_3_6_0_jar.xml +0 -13
  100. package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_13_0_jar.xml +0 -13
  101. package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml +0 -13
  102. package/android/.idea/libraries/Gradle__org_webkit_android_jsc_r174650_aar.xml +0 -11
  103. package/android/.idea/misc.xml +0 -14
  104. package/android/.idea/modules.xml +0 -8
  105. package/android/.idea/runConfigurations.xml +0 -12
  106. package/android/.idea/vcs.xml +0 -6
  107. package/android/.idea/workspace.xml +0 -317
  108. package/android/build/generated/source/buildConfig/androidTest/debug/com/clevertap/react/test/BuildConfig.java +0 -13
  109. package/android/build/intermediates/annotation_processor_list/debugUnitTest/annotationProcessors.json +0 -1
  110. package/android/build/intermediates/javac/debugUnitTest/classes/com/clevertap/react/CleverTapModuleTest.class +0 -0
  111. package/android/build/intermediates/manifest_merge_blame_file/debugAndroidTest/manifest-merger-blame-debug-androidTest-report.txt +0 -98
  112. package/android/build/intermediates/merged_manifests/debugAndroidTest/AndroidManifest.xml +0 -57
  113. package/android/build/intermediates/merged_manifests/debugAndroidTest/output.json +0 -1
  114. package/android/build/intermediates/packaged-classes/debug/classes.jar +0 -0
  115. package/android/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt +0 -1474
  116. package/android/build/intermediates/symbols/debug/R.txt +0 -2034
  117. package/clevertap-logo.png +0 -0
@@ -1,19 +1,16 @@
1
1
  package com.clevertap.react;
2
2
 
3
- import android.annotation.SuppressLint;
4
3
  import android.location.Location;
5
4
  import android.net.Uri;
6
5
  import android.os.Build.VERSION;
7
6
  import android.os.Build.VERSION_CODES;
8
7
  import android.os.Bundle;
9
8
  import android.util.Log;
10
- import com.clevertap.android.sdk.CTExperimentsListener;
9
+ import androidx.annotation.RequiresApi;
11
10
  import com.clevertap.android.sdk.CTFeatureFlagsListener;
12
11
  import com.clevertap.android.sdk.CTInboxListener;
13
- import com.clevertap.android.sdk.CTInboxMessage;
14
12
  import com.clevertap.android.sdk.CTInboxStyleConfig;
15
13
  import com.clevertap.android.sdk.CleverTapAPI;
16
- import com.clevertap.android.sdk.EventDetail;
17
14
  import com.clevertap.android.sdk.InAppNotificationButtonListener;
18
15
  import com.clevertap.android.sdk.InAppNotificationListener;
19
16
  import com.clevertap.android.sdk.InboxMessageButtonListener;
@@ -21,7 +18,10 @@ import com.clevertap.android.sdk.SyncListener;
21
18
  import com.clevertap.android.sdk.UTMDetail;
22
19
  import com.clevertap.android.sdk.displayunits.DisplayUnitListener;
23
20
  import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
21
+ import com.clevertap.android.sdk.events.EventDetail;
24
22
  import com.clevertap.android.sdk.featureFlags.CTFeatureFlagsController;
23
+ import com.clevertap.android.sdk.inbox.CTInboxMessage;
24
+ import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
25
25
  import com.clevertap.android.sdk.product_config.CTProductConfigController;
26
26
  import com.clevertap.android.sdk.product_config.CTProductConfigListener;
27
27
  import com.clevertap.android.sdk.pushnotification.CTPushNotificationListener;
@@ -50,15 +50,42 @@ import org.json.JSONArray;
50
50
  import org.json.JSONException;
51
51
  import org.json.JSONObject;
52
52
 
53
+ @SuppressWarnings({"unused", "RedundantSuppression"})
53
54
  public class CleverTapModule extends ReactContextBaseJavaModule implements SyncListener,
54
55
  InAppNotificationListener, CTInboxListener,
55
- CTExperimentsListener, InboxMessageButtonListener,
56
+ InboxMessageButtonListener,
56
57
  InAppNotificationButtonListener, DisplayUnitListener, CTProductConfigListener,
57
58
  CTFeatureFlagsListener, CTPushNotificationListener {
58
59
 
59
- private ReactApplicationContext context;
60
+ @SuppressWarnings("FieldCanBeLocal")
61
+ private enum InBoxMessages {
62
+ ALL(0),
63
+ UNREAD(1);
60
64
 
61
- private CleverTapAPI mCleverTap;
65
+ private final int value;
66
+
67
+ InBoxMessages(final int newValue) {
68
+ value = newValue;
69
+ }
70
+
71
+ }
72
+
73
+ private enum ErrorMessages {
74
+
75
+ CLEVERTAP_NOT_INITIALIZED("CleverTap not initialized"),
76
+ PRODUCTCONFIG_NOT_INITIALIZED("Product Config not initialized"),
77
+ FF_NOT_INITIALIZED("Feature Flags not initialized");
78
+
79
+ private final String errorMessage;
80
+
81
+ ErrorMessages(String s) {
82
+ errorMessage = s;
83
+ }
84
+
85
+ public String getErrorMessage() {
86
+ return errorMessage;
87
+ }
88
+ }
62
89
 
63
90
  private static Uri mlaunchURI;
64
91
 
@@ -84,8 +111,6 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
84
111
 
85
112
  private static final String CLEVERTAP_INBOX_MESSAGES_DID_UPDATE = "CleverTapInboxMessagesDidUpdate";
86
113
 
87
- private static final String CLEVERTAP_EXPERIMENTS_DID_UPDATE = "CleverTapExperimentsDidUpdate";
88
-
89
114
  private static final String CLEVERTAP_ON_INBOX_BUTTON_CLICK = "CleverTapInboxMessageButtonTapped";
90
115
 
91
116
  private static final String CLEVERTAP_ON_INAPP_BUTTON_CLICK = "CleverTapInAppNotificationButtonTapped";
@@ -102,157 +127,57 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
102
127
 
103
128
  private static final String CLEVERTAP_PUSH_NOTIFICATION_CLICKED = "CleverTapPushNotificationClicked";
104
129
 
105
- private enum InBoxMessages {
106
- ALL(0),
107
- UNREAD(1);
108
-
109
- private final int value;
110
-
111
- InBoxMessages(final int newValue) {
112
- value = newValue;
113
- }
114
-
115
- }
116
-
117
- private enum ErrorMessages {
118
-
119
- CLEVERTAP_NOT_INITIALIZED("CleverTap not initialized"),
120
- PRODUCTCONFIG_NOT_INITIALIZED("Product Config not initialized"),
121
- FF_NOT_INITIALIZED("Feature Flags not initialized");
122
-
123
- private final String errorMessage;
124
-
125
- ErrorMessages(String s) {
126
- errorMessage = s;
127
- }
130
+ private final ReactApplicationContext context;
128
131
 
129
- public String getErrorMessage() {
130
- return errorMessage;
131
- }
132
- }
132
+ private CleverTapAPI mCleverTap;
133
133
 
134
134
  public static void setInitialUri(final Uri uri) {
135
135
  mlaunchURI = uri;
136
136
  }
137
137
 
138
- @Override
139
- public String getName() {
140
- return REACT_MODULE_NAME;
141
- }
142
-
143
- @Override
144
- public Map<String, Object> getConstants() {
145
- final Map<String, Object> constants = new HashMap<>();
146
- constants.put(CLEVERTAP_PROFILE_DID_INITIALIZE, CLEVERTAP_PROFILE_DID_INITIALIZE);
147
- constants.put(CLEVERTAP_PROFILE_SYNC, CLEVERTAP_PROFILE_SYNC);
148
- constants.put(CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED, CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED);
149
- constants.put(FCM, FCM);
150
- constants.put(XPS, XPS);
151
- constants.put(BPS, BPS);
152
- constants.put(HPS, HPS);
153
- constants.put(CLEVERTAP_INBOX_DID_INITIALIZE, CLEVERTAP_INBOX_DID_INITIALIZE);
154
- constants.put(CLEVERTAP_INBOX_MESSAGES_DID_UPDATE, CLEVERTAP_INBOX_MESSAGES_DID_UPDATE);
155
- constants.put(CLEVERTAP_ON_INBOX_BUTTON_CLICK, CLEVERTAP_ON_INBOX_BUTTON_CLICK);
156
- constants.put(CLEVERTAP_ON_DISPLAY_UNITS_LOADED, CLEVERTAP_ON_DISPLAY_UNITS_LOADED);
157
- constants.put(CLEVERTAP_ON_INAPP_BUTTON_CLICK, CLEVERTAP_ON_INAPP_BUTTON_CLICK);
158
- constants.put(CLEVERTAP_FEATURE_FLAGS_DID_UPDATE, CLEVERTAP_FEATURE_FLAGS_DID_UPDATE);
159
- constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE, CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE);
160
- constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_FETCH, CLEVERTAP_PRODUCT_CONFIG_DID_FETCH);
161
- constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE, CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE);
162
- constants.put(CLEVERTAP_PUSH_NOTIFICATION_CLICKED, CLEVERTAP_PUSH_NOTIFICATION_CLICKED);
163
- return constants;
164
- }
165
-
166
138
  public CleverTapModule(ReactApplicationContext reactContext) {
167
139
  super(reactContext);
168
140
  this.context = reactContext;
169
141
  getCleverTapAPI();
170
142
  }
171
143
 
172
- private CleverTapAPI getCleverTapAPI() {
173
- if (mCleverTap == null) {
174
- CleverTapAPI clevertap = CleverTapAPI.getDefaultInstance(this.context);
175
- if (clevertap != null) {
176
- clevertap.setCTPushNotificationListener(this);
177
- clevertap.setInAppNotificationListener(this);
178
- clevertap.setSyncListener(this);
179
- clevertap.setCTNotificationInboxListener(this);
180
- clevertap.setCTExperimentsListener(this);
181
- clevertap.setInboxMessageButtonListener(this);
182
- clevertap.setInAppNotificationButtonListener(this);
183
- clevertap.setDisplayUnitListener(this);
184
- clevertap.setCTProductConfigListener(this);
185
- clevertap.setCTFeatureFlagsListener(this);
186
- clevertap.setLibrary("React-Native");
187
- }
188
- mCleverTap = clevertap;
189
- }
190
-
191
- return mCleverTap;
192
- }
193
-
194
- // launch
195
-
196
- @ReactMethod
197
- public void getInitialUrl(Callback callback) {
198
- String error = null;
199
- String url = null;
200
-
201
- if (mlaunchURI == null) {
202
- error = "CleverTap InitialUrl is null";
203
- } else {
204
- url = mlaunchURI.toString();
205
- }
206
- callbackWithErrorAndResult(callback, error, url);
207
- }
208
-
209
- // push
210
-
211
- @ReactMethod
212
- public void registerForPush() {
213
- // no-op in Android
214
- Log.i(TAG, "CleverTap.registerForPush is a no-op in Android");
215
- }
216
-
217
144
  @ReactMethod
218
- public void setPushTokenAsString(String token, String type) {
219
- CleverTapAPI clevertap = getCleverTapAPI();
220
- if (clevertap == null || token == null || type == null) {
145
+ public void activate() {
146
+ CTProductConfigController productConfigController = getCtProductConfigController();
147
+ if (productConfigController == null) {
221
148
  return;
222
149
  }
150
+ productConfigController.activate();
151
+ }
223
152
 
224
- switch (type) {
225
- case FCM:
226
- clevertap.pushFcmRegistrationId(token, true);
227
- break;
228
- case XPS:
229
- clevertap.pushXiaomiRegistrationId(token, true);
230
- break;
231
- case BPS:
232
- clevertap.pushBaiduRegistrationId(token, true);
233
- break;
234
- case HPS:
235
- clevertap.pushHuaweiRegistrationId(token, true);
236
- break;
237
- default:
238
- Log.e(TAG, "Unknown push token type " + type);
239
- break;
240
- }
153
+ // InAppNotificationListener
154
+ public boolean beforeShow(Map<String, Object> var1) {
155
+ return true;
241
156
  }
242
157
 
243
- //UI Editor connection
158
+ //Custom Push Notification
244
159
  @ReactMethod
245
- public void setUIEditorConnectionEnabled(boolean enabled) {
160
+ public void createNotification(ReadableMap extras) {
246
161
  CleverTapAPI clevertap = getCleverTapAPI();
247
162
  if (clevertap == null) {
248
163
  return;
249
164
  }
250
- CleverTapAPI.setUIEditorConnectionEnabled(enabled);
251
- Log.i(TAG, "UI Editor connection enabled - " + enabled);
165
+ JSONObject extrasJsonObject;
166
+ try {
167
+ extrasJsonObject = jsonObjectFromReadableMap(extras);
168
+ Bundle bundle = new Bundle();
169
+ for (Iterator<String> entry = extrasJsonObject.keys(); entry.hasNext(); ) {
170
+ String key = entry.next();
171
+ String str = extrasJsonObject.optString(key);
172
+ bundle.putString(key, str);
173
+ }
174
+ CleverTapAPI.createNotification(this.context, bundle);
175
+ } catch (JSONException e) {
176
+ e.printStackTrace();
177
+ }
252
178
  }
253
179
 
254
- //notification channel/group methods for Android O
255
-
180
+ @RequiresApi(api = VERSION_CODES.O)
256
181
  @ReactMethod
257
182
  public void createNotificationChannel(String channelId, String channelName, String channelDescription,
258
183
  int importance, boolean showBadge) {
@@ -265,19 +190,18 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
265
190
  Log.i(TAG, "Notification Channel " + channelName + " created");
266
191
  }
267
192
 
193
+ @RequiresApi(api = VERSION_CODES.O)
268
194
  @ReactMethod
269
- public void createNotificationChannelWithSound(String channelId, String channelName, String channelDescription,
270
- int importance, boolean showBadge, String sound) {
195
+ public void createNotificationChannelGroup(String groupId, String groupName) {
271
196
  CleverTapAPI clevertap = getCleverTapAPI();
272
- if (clevertap == null || channelId == null || channelName == null || channelDescription == null
273
- || sound == null) {
197
+ if (clevertap == null || groupId == null || groupName == null) {
274
198
  return;
275
199
  }
276
- CleverTapAPI.createNotificationChannel(this.context, channelId, channelName, channelDescription, importance,
277
- showBadge, sound);
278
- Log.i(TAG, "Notification Channel " + channelName + " with sound file " + sound + " created");
200
+ CleverTapAPI.createNotificationChannelGroup(this.context, groupId, groupName);
201
+ Log.i(TAG, "Notification Channel Group " + groupName + " created");
279
202
  }
280
203
 
204
+ @RequiresApi(api = VERSION_CODES.O)
281
205
  @ReactMethod
282
206
  public void createNotificationChannelWithGroupId(String channelId, String channelName, String channelDescription,
283
207
  int importance, String groupId, boolean showBadge) {
@@ -291,6 +215,7 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
291
215
  Log.i(TAG, "Notification Channel " + channelName + " with Group Id " + groupId + " created");
292
216
  }
293
217
 
218
+ @RequiresApi(api = VERSION_CODES.O)
294
219
  @ReactMethod
295
220
  public void createNotificationChannelWithGroupIdAndSound(String channelId, String channelName,
296
221
  String channelDescription, int importance, String groupId, boolean showBadge, String sound) {
@@ -305,16 +230,31 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
305
230
  + " created");
306
231
  }
307
232
 
233
+ @RequiresApi(api = VERSION_CODES.O)
308
234
  @ReactMethod
309
- public void createNotificationChannelGroup(String groupId, String groupName) {
235
+ public void createNotificationChannelWithSound(String channelId, String channelName, String channelDescription,
236
+ int importance, boolean showBadge, String sound) {
310
237
  CleverTapAPI clevertap = getCleverTapAPI();
311
- if (clevertap == null || groupId == null || groupName == null) {
238
+ if (clevertap == null || channelId == null || channelName == null || channelDescription == null
239
+ || sound == null) {
312
240
  return;
313
241
  }
314
- CleverTapAPI.createNotificationChannelGroup(this.context, groupId, groupName);
315
- Log.i(TAG, "Notification Channel Group " + groupName + " created");
242
+ CleverTapAPI.createNotificationChannel(this.context, channelId, channelName, channelDescription, importance,
243
+ showBadge, sound);
244
+ Log.i(TAG, "Notification Channel " + channelName + " with sound file " + sound + " created");
245
+ }
246
+
247
+ @ReactMethod
248
+ public void deleteInboxMessageForId(String messageId) {
249
+ CleverTapAPI cleverTap = getCleverTapAPI();
250
+ if (cleverTap != null) {
251
+ cleverTap.deleteInboxMessage(messageId);
252
+ } else {
253
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
254
+ }
316
255
  }
317
256
 
257
+ @RequiresApi(api = VERSION_CODES.O)
318
258
  @ReactMethod
319
259
  public void deleteNotificationChannel(String channelId) {
320
260
  CleverTapAPI clevertap = getCleverTapAPI();
@@ -325,6 +265,7 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
325
265
  Log.i(TAG, "Notification Channel Id " + channelId + " deleted");
326
266
  }
327
267
 
268
+ @RequiresApi(api = VERSION_CODES.O)
328
269
  @ReactMethod
329
270
  public void deleteNotificationChannelGroup(String groupId) {
330
271
  CleverTapAPI clevertap = getCleverTapAPI();
@@ -335,189 +276,231 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
335
276
  Log.i(TAG, "Notification Channel Group Id " + groupId + " deleted");
336
277
  }
337
278
 
338
- //Custom Push Notification
339
279
  @ReactMethod
340
- public void createNotification(ReadableMap extras) {
280
+ public void disablePersonalization() {
341
281
  CleverTapAPI clevertap = getCleverTapAPI();
342
282
  if (clevertap == null) {
343
283
  return;
344
284
  }
345
- JSONObject extrasJsonObject;
346
- try {
347
- extrasJsonObject = jsonObjectFromReadableMap(extras);
348
- Bundle bundle = new Bundle();
349
- for (Iterator<String> entry = extrasJsonObject.keys(); entry.hasNext(); ) {
350
- String key = entry.next();
351
- String str = extrasJsonObject.optString(key);
352
- bundle.putString(key, str);
353
- }
354
- CleverTapAPI.createNotification(this.context, bundle);
355
- } catch (JSONException e) {
356
- e.printStackTrace();
357
- }
285
+ clevertap.disablePersonalization();
358
286
  }
359
287
 
360
- //Enables tracking opt out for the currently active user.
361
-
362
288
  @ReactMethod
363
- public void setOptOut(boolean value) {
289
+ public void enableDeviceNetworkInfoReporting(boolean value) {
364
290
  CleverTapAPI clevertap = getCleverTapAPI();
365
291
  if (clevertap == null) {
366
292
  return;
367
293
  }
368
- clevertap.setOptOut(value);
294
+ clevertap.enableDeviceNetworkInfoReporting(value);
369
295
  }
370
296
 
371
- //Sets the SDK to offline mode
372
297
  @ReactMethod
373
- public void setOffline(boolean value) {
298
+ public void enablePersonalization() {
374
299
  CleverTapAPI clevertap = getCleverTapAPI();
375
300
  if (clevertap == null) {
376
301
  return;
377
302
  }
378
- clevertap.setOffline(value);
303
+ clevertap.enablePersonalization();
379
304
  }
380
305
 
381
- //Enables the reporting of device network-related information, including IP address. This reporting is disabled by default.
306
+ //Enables tracking opt out for the currently active user.
382
307
 
383
308
  @ReactMethod
384
- public void enableDeviceNetworkInfoReporting(boolean value) {
385
- CleverTapAPI clevertap = getCleverTapAPI();
386
- if (clevertap == null) {
387
- return;
388
- }
389
- clevertap.enableDeviceNetworkInfoReporting(value);
390
- }
391
-
392
- // Personalization
309
+ public void eventGetDetail(String eventName, Callback callback) {
310
+ String error = null;
311
+ WritableMap result = null;
393
312
 
394
- @ReactMethod
395
- public void enablePersonalization() {
396
313
  CleverTapAPI clevertap = getCleverTapAPI();
397
- if (clevertap == null) {
398
- return;
314
+ if (clevertap != null) {
315
+ EventDetail detail = clevertap.getDetails(eventName);
316
+ result = eventDetailToWritableMap(detail);
317
+ } else {
318
+ error = "CleverTap not initialized";
399
319
  }
400
- clevertap.enablePersonalization();
320
+ callbackWithErrorAndResult(callback, error, result);
401
321
  }
402
322
 
403
323
  @ReactMethod
404
- public void disablePersonalization() {
324
+ public void eventGetFirstTime(String eventName, Callback callback) {
325
+ String error = null;
326
+ int result = -1;
327
+
405
328
  CleverTapAPI clevertap = getCleverTapAPI();
406
- if (clevertap == null) {
407
- return;
329
+ if (clevertap != null) {
330
+ result = clevertap.getFirstTime(eventName);
331
+ } else {
332
+ error = "CleverTap not initialized";
408
333
  }
409
- clevertap.disablePersonalization();
334
+ callbackWithErrorAndResult(callback, error, result);
410
335
  }
411
336
 
412
- // Event API
337
+ //Enables the reporting of device network-related information, including IP address. This reporting is disabled by default.
413
338
 
414
339
  @ReactMethod
415
- public void recordScreenView(String screenName) {
340
+ public void eventGetLastTime(String eventName, Callback callback) {
341
+ String error = null;
342
+ int result = -1;
343
+
416
344
  CleverTapAPI clevertap = getCleverTapAPI();
417
- if (clevertap == null) {
418
- return;
345
+ if (clevertap != null) {
346
+ result = clevertap.getLastTime(eventName);
347
+ } else {
348
+ error = "CleverTap not initialized";
419
349
  }
420
- clevertap.recordScreen(screenName);
350
+ callbackWithErrorAndResult(callback, error, result);
421
351
  }
422
352
 
353
+ // Personalization
354
+
423
355
  @ReactMethod
424
- public void recordEvent(String eventName, ReadableMap props) {
356
+ public void eventGetOccurrences(String eventName, Callback callback) {
357
+ String error = null;
358
+ int result = -1;
359
+
425
360
  CleverTapAPI clevertap = getCleverTapAPI();
426
- if (clevertap == null) {
427
- return;
361
+ if (clevertap != null) {
362
+ result = clevertap.getCount(eventName);
363
+ } else {
364
+ error = "CleverTap not initialized";
428
365
  }
366
+ callbackWithErrorAndResult(callback, error, result);
367
+ }
429
368
 
430
- Map<String, Object> finalProps = eventPropsFromReadableMap(props, Object.class);
369
+ //Feature Flags Callback
370
+ @Override
371
+ public void featureFlagsUpdated() {
372
+ WritableMap params = Arguments.createMap();
373
+ sendEvent(CLEVERTAP_FEATURE_FLAGS_DID_UPDATE, params);//passing empty map
374
+ }
431
375
 
432
- if (finalProps == null) {
433
- clevertap.pushEvent(eventName);
434
- } else {
435
- clevertap.pushEvent(eventName, finalProps);
376
+ // Event API
377
+
378
+ @ReactMethod
379
+ public void fetch() {
380
+ CTProductConfigController productConfigController = getCtProductConfigController();
381
+ if (productConfigController == null) {
382
+ return;
436
383
  }
384
+
385
+ productConfigController.fetch();
437
386
  }
438
387
 
439
388
  @ReactMethod
440
- public void recordChargedEvent(ReadableMap details, ReadableArray items) {
441
- CleverTapAPI clevertap = getCleverTapAPI();
442
- if (clevertap == null || details == null) {
389
+ public void fetchAndActivate() {
390
+ CTProductConfigController productConfigController = getCtProductConfigController();
391
+ if (productConfigController == null) {
443
392
  return;
444
393
  }
445
394
 
446
- HashMap<String, Object> finalDetails = eventPropsFromReadableMap(details, Object.class);
447
-
448
- ArrayList<HashMap<String, Object>> finalItems = new ArrayList<>();
395
+ productConfigController.fetchAndActivate();
396
+ }
449
397
 
450
- if (items != null) {
451
- for (int i = 0; i < items.size(); i++) {
452
- try {
453
- HashMap<String, Object> item = eventPropsFromReadableMap(items.getMap(i), Object.class);
454
- finalItems.add(item);
455
- } catch (Throwable t) {
456
- Log.e(TAG, t.getLocalizedMessage());
457
- }
458
- }
398
+ @ReactMethod
399
+ public void fetchWithMinimumFetchIntervalInSeconds(int interval) {
400
+ CTProductConfigController productConfigController = getCtProductConfigController();
401
+ if (productConfigController == null) {
402
+ return;
459
403
  }
460
404
 
461
- try {
462
- clevertap.pushChargedEvent(finalDetails, finalItems);
463
- } catch (Throwable t) {
464
- Log.e(TAG, t.getLocalizedMessage());
465
- }
405
+ productConfigController.fetch(interval);
466
406
  }
467
407
 
468
408
  @ReactMethod
469
- public void eventGetFirstTime(String eventName, Callback callback) {
409
+ public void getAllDisplayUnits(Callback callback) {
470
410
  String error = null;
471
- int result = -1;
411
+ WritableArray result = Arguments.createArray();
472
412
 
473
- CleverTapAPI clevertap = getCleverTapAPI();
474
- if (clevertap != null) {
475
- result = clevertap.getFirstTime(eventName);
413
+ CleverTapAPI cleverTap = getCleverTapAPI();
414
+ if (cleverTap != null) {
415
+ result = getWritableArrayFromList(cleverTap.getAllDisplayUnits());
476
416
  } else {
477
- error = "CleverTap not initialized";
417
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
478
418
  }
479
419
  callbackWithErrorAndResult(callback, error, result);
480
420
  }
481
421
 
482
422
  @ReactMethod
483
- public void eventGetLastTime(String eventName, Callback callback) {
423
+ public void getAllInboxMessages(Callback callback) {
424
+
425
+ getInboxMessages(callback, InBoxMessages.ALL);
426
+ }
427
+
428
+ @ReactMethod
429
+ public void getBoolean(String key, Callback callback) {
484
430
  String error = null;
485
- int result = -1;
431
+ Boolean result = null;
486
432
 
487
- CleverTapAPI clevertap = getCleverTapAPI();
488
- if (clevertap != null) {
489
- result = clevertap.getLastTime(eventName);
433
+ CleverTapAPI cleverTap = getCleverTapAPI();
434
+ if (cleverTap != null) {
435
+ CTProductConfigController productConfigController = cleverTap.productConfig();
436
+ if (productConfigController != null) {
437
+ result = productConfigController.getBoolean(key);
438
+ } else {
439
+ error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
440
+ }
490
441
  } else {
491
- error = "CleverTap not initialized";
442
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
492
443
  }
493
444
  callbackWithErrorAndResult(callback, error, result);
494
445
  }
495
446
 
447
+ @Override
448
+ public Map<String, Object> getConstants() {
449
+ final Map<String, Object> constants = new HashMap<>();
450
+ constants.put(CLEVERTAP_PROFILE_DID_INITIALIZE, CLEVERTAP_PROFILE_DID_INITIALIZE);
451
+ constants.put(CLEVERTAP_PROFILE_SYNC, CLEVERTAP_PROFILE_SYNC);
452
+ constants.put(CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED, CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED);
453
+ constants.put(FCM, FCM);
454
+ constants.put(XPS, XPS);
455
+ constants.put(BPS, BPS);
456
+ constants.put(HPS, HPS);
457
+ constants.put(CLEVERTAP_INBOX_DID_INITIALIZE, CLEVERTAP_INBOX_DID_INITIALIZE);
458
+ constants.put(CLEVERTAP_INBOX_MESSAGES_DID_UPDATE, CLEVERTAP_INBOX_MESSAGES_DID_UPDATE);
459
+ constants.put(CLEVERTAP_ON_INBOX_BUTTON_CLICK, CLEVERTAP_ON_INBOX_BUTTON_CLICK);
460
+ constants.put(CLEVERTAP_ON_DISPLAY_UNITS_LOADED, CLEVERTAP_ON_DISPLAY_UNITS_LOADED);
461
+ constants.put(CLEVERTAP_ON_INAPP_BUTTON_CLICK, CLEVERTAP_ON_INAPP_BUTTON_CLICK);
462
+ constants.put(CLEVERTAP_FEATURE_FLAGS_DID_UPDATE, CLEVERTAP_FEATURE_FLAGS_DID_UPDATE);
463
+ constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE, CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE);
464
+ constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_FETCH, CLEVERTAP_PRODUCT_CONFIG_DID_FETCH);
465
+ constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE, CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE);
466
+ constants.put(CLEVERTAP_PUSH_NOTIFICATION_CLICKED, CLEVERTAP_PUSH_NOTIFICATION_CLICKED);
467
+ return constants;
468
+ }
469
+
470
+ // Profile API
471
+
496
472
  @ReactMethod
497
- public void eventGetOccurrences(String eventName, Callback callback) {
473
+ public void getDisplayUnitForId(String unitID, Callback callback) {
498
474
  String error = null;
499
- int result = -1;
475
+ String result = null;
500
476
 
501
- CleverTapAPI clevertap = getCleverTapAPI();
502
- if (clevertap != null) {
503
- result = clevertap.getCount(eventName);
477
+ CleverTapAPI cleverTap = getCleverTapAPI();
478
+ if (cleverTap != null) {
479
+ CleverTapDisplayUnit displayUnit = cleverTap.getDisplayUnitForId(unitID);
480
+ if (displayUnit != null && displayUnit.getJsonObject() != null) {
481
+ result = displayUnit.getJsonObject().toString();
482
+ }
504
483
  } else {
505
- error = "CleverTap not initialized";
484
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
506
485
  }
507
486
  callbackWithErrorAndResult(callback, error, result);
508
487
  }
509
488
 
510
489
  @ReactMethod
511
- public void eventGetDetail(String eventName, Callback callback) {
490
+ public void getDouble(String key, Callback callback) {
512
491
  String error = null;
513
- WritableMap result = null;
492
+ Double result = null;
514
493
 
515
- CleverTapAPI clevertap = getCleverTapAPI();
516
- if (clevertap != null) {
517
- EventDetail detail = clevertap.getDetails(eventName);
518
- result = eventDetailToWritableMap(detail);
494
+ CleverTapAPI cleverTap = getCleverTapAPI();
495
+ if (cleverTap != null) {
496
+ CTProductConfigController productConfigController = cleverTap.productConfig();
497
+ if (productConfigController != null) {
498
+ result = productConfigController.getDouble(key);
499
+ } else {
500
+ error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
501
+ }
519
502
  } else {
520
- error = "CleverTap not initialized";
503
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
521
504
  }
522
505
  callbackWithErrorAndResult(callback, error, result);
523
506
  }
@@ -537,28 +520,34 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
537
520
  callbackWithErrorAndResult(callback, error, result);
538
521
  }
539
522
 
540
- // Profile API
541
-
542
523
  @ReactMethod
543
- public void setLocation(double latitude, double longitude) {
544
- CleverTapAPI clevertap = getCleverTapAPI();
545
- if (clevertap == null) {
546
- return;
524
+ public void getFeatureFlag(String name, Boolean defaultValue, Callback callback) {
525
+ String error = null;
526
+ Boolean result = null;
527
+
528
+ CleverTapAPI cleverTap = getCleverTapAPI();
529
+ if (cleverTap != null) {
530
+ CTFeatureFlagsController featureFlagsController = cleverTap.featureFlag();
531
+ if (featureFlagsController != null) {
532
+ result = featureFlagsController.get(name, defaultValue);
533
+ } else {
534
+ error = ErrorMessages.FF_NOT_INITIALIZED.getErrorMessage();
535
+ }
536
+ } else {
537
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
547
538
  }
548
- final Location location = new Location("CleverTapReact");
549
- location.setLatitude(latitude);
550
- location.setLongitude(longitude);
551
- clevertap.setLocation(location);
539
+ callbackWithErrorAndResult(callback, error, result);
552
540
  }
553
541
 
554
542
  @ReactMethod
555
- public void profileGetCleverTapAttributionIdentifier(Callback callback) {
543
+ public void getInboxMessageCount(Callback callback) {
544
+
556
545
  String error = null;
557
- String result = null;
546
+ int result = -1;
558
547
 
559
- CleverTapAPI clevertap = getCleverTapAPI();
560
- if (clevertap != null) {
561
- result = clevertap.getCleverTapAttributionIdentifier();
548
+ CleverTapAPI cleverTap = getCleverTapAPI();
549
+ if (cleverTap != null) {
550
+ result = cleverTap.getInboxMessageCount();
562
551
  } else {
563
552
  error = "CleverTap not initialized";
564
553
  }
@@ -566,224 +555,108 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
566
555
  }
567
556
 
568
557
  @ReactMethod
569
- public void profileGetCleverTapID(Callback callback) {
558
+ public void getInboxMessageForId(String messageId, Callback callback) {
570
559
  String error = null;
571
560
  String result = null;
572
561
 
573
- CleverTapAPI clevertap = getCleverTapAPI();
574
- if (clevertap != null) {
575
- result = clevertap.getCleverTapID();
562
+ CleverTapAPI cleverTap = getCleverTapAPI();
563
+ if (cleverTap != null) {
564
+ CTInboxMessage inboxMessage = cleverTap.getInboxMessageForId(messageId);
565
+
566
+ if (inboxMessage != null && inboxMessage.getData() != null) {
567
+ result = inboxMessage.getData().toString();
568
+ }
576
569
  } else {
577
- error = "CleverTap not initialized";
570
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
578
571
  }
579
572
  callbackWithErrorAndResult(callback, error, result);
580
573
  }
581
574
 
582
575
  @ReactMethod
583
- public void onUserLogin(ReadableMap profile) {
584
- CleverTapAPI clevertap = getCleverTapAPI();
585
- if (clevertap == null) {
586
- return;
587
- }
576
+ public void getInboxMessageUnreadCount(Callback callback) {
577
+ String error = null;
578
+ int result = -1;
588
579
 
589
- Map<String, Object> finalProfile = profileFromReadableMap(profile);
590
- clevertap.onUserLogin(finalProfile);
580
+ CleverTapAPI cleverTap = getCleverTapAPI();
581
+ if (cleverTap != null) {
582
+ result = cleverTap.getInboxMessageUnreadCount();
583
+ } else {
584
+ error = "CleverTap not initialized";
585
+ }
586
+ callbackWithErrorAndResult(callback, error, result);
591
587
  }
592
588
 
593
589
  @ReactMethod
594
- public void profileSet(ReadableMap profile) {
595
- CleverTapAPI clevertap = getCleverTapAPI();
596
- if (clevertap == null) {
597
- return;
598
- }
599
-
600
- Map<String, Object> finalProfile = profileFromReadableMap(profile);
601
- clevertap.pushProfile(finalProfile);
602
- }
603
-
604
- @ReactMethod
605
- public void profileSetGraphUser(ReadableMap profile) {
606
- CleverTapAPI clevertap = getCleverTapAPI();
607
- if (clevertap == null) {
608
- return;
609
- }
590
+ public void getInitialUrl(Callback callback) {
591
+ String error = null;
592
+ String url = null;
610
593
 
611
- try {
612
- JSONObject finalProfile = jsonObjectFromReadableMap(profile);
613
- clevertap.pushFacebookUser(finalProfile);
614
- } catch (Throwable t) {
615
- Log.e(TAG, t.getLocalizedMessage());
594
+ if (mlaunchURI == null) {
595
+ error = "CleverTap InitialUrl is null";
596
+ } else {
597
+ url = mlaunchURI.toString();
616
598
  }
599
+ callbackWithErrorAndResult(callback, error, url);
617
600
  }
618
601
 
619
602
  @ReactMethod
620
- @SuppressWarnings("unchecked")
621
- public void profileGetProperty(String propertyName, Callback callback) {
603
+ public void getLastFetchTimeStampInMillis(Callback callback) {
622
604
  String error = null;
623
- Object result = null;
605
+ String result = null;
624
606
 
625
- CleverTapAPI clevertap = getCleverTapAPI();
626
- if (clevertap != null) {
627
- Object value = clevertap.getProperty(propertyName);
628
- // Handle JSONArray for multi-values, otherwise everything should be primitive or String
629
- if (value instanceof JSONArray) {
630
- JSONArray valueArray = (JSONArray) value;
631
- WritableArray writableArray = Arguments.createArray();
632
- for (int i = 0; i < valueArray.length(); i++) {
633
- try {
634
- writableArray.pushString(valueArray.get(i).toString());
635
- } catch (JSONException e) {
636
- //no-op
637
- }
638
- }
639
- result = writableArray;
607
+ CleverTapAPI cleverTap = getCleverTapAPI();
608
+ if (cleverTap != null) {
609
+ CTProductConfigController productConfigController = cleverTap.productConfig();
610
+ if (productConfigController != null) {
611
+ result = String.valueOf(productConfigController.getLastFetchTimeStampInMillis());
640
612
  } else {
641
- result = value;
613
+ error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
642
614
  }
643
-
644
615
  } else {
645
- error = "CleverTap not initialized";
616
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
646
617
  }
647
618
  callbackWithErrorAndResult(callback, error, result);
648
619
  }
649
620
 
650
- @ReactMethod
651
- public void profileRemoveValueForKey(String key) {
652
- CleverTapAPI clevertap = getCleverTapAPI();
653
- if (clevertap == null) {
654
- return;
655
- }
656
- clevertap.removeValueForKey(key);
657
- }
658
-
659
- @ReactMethod
660
- public void profileSetMultiValues(ReadableArray values, String key) {
661
- CleverTapAPI clevertap = getCleverTapAPI();
662
- if (clevertap == null) {
663
- return;
664
- }
665
- ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
666
- clevertap.setMultiValuesForKey(key, finalValues);
667
- }
668
-
669
- @ReactMethod
670
- public void profileAddMultiValue(String value, String key) {
671
- CleverTapAPI clevertap = getCleverTapAPI();
672
- if (clevertap == null) {
673
- return;
674
- }
675
- clevertap.addMultiValueForKey(key, value);
676
- }
677
-
678
- @ReactMethod
679
- public void profileAddMultiValues(ReadableArray values, String key) {
680
- CleverTapAPI clevertap = getCleverTapAPI();
681
- if (clevertap == null) {
682
- return;
683
- }
684
- ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
685
- clevertap.addMultiValuesForKey(key, finalValues);
686
- }
687
-
688
- @ReactMethod
689
- public void profileRemoveMultiValue(String value, String key) {
690
- CleverTapAPI clevertap = getCleverTapAPI();
691
- if (clevertap == null) {
692
- return;
693
- }
694
- clevertap.removeMultiValueForKey(key, value);
695
- }
696
-
697
- @ReactMethod
698
- public void profileRemoveMultiValues(ReadableArray values, String key) {
699
- CleverTapAPI clevertap = getCleverTapAPI();
700
- if (clevertap == null) {
701
- return;
702
- }
703
- ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
704
- clevertap.removeMultiValuesForKey(key, finalValues);
705
- }
706
-
707
- // Session API
708
-
709
- @ReactMethod
710
- public void pushInstallReferrer(String source, String medium, String campaign) {
711
- CleverTapAPI clevertap = getCleverTapAPI();
712
- if (clevertap == null) {
713
- return;
714
- }
715
- clevertap.pushInstallReferrer(source, medium, campaign);
716
- }
717
-
718
- @ReactMethod
719
- public void sessionGetTimeElapsed(Callback callback) {
720
- String error = null;
721
- int result = -1;
722
-
723
- CleverTapAPI clevertap = getCleverTapAPI();
724
- if (clevertap != null) {
725
- result = clevertap.getTimeElapsed();
726
- } else {
727
- error = "CleverTap not initialized";
728
- }
729
- callbackWithErrorAndResult(callback, error, result);
621
+ @Override
622
+ public String getName() {
623
+ return REACT_MODULE_NAME;
730
624
  }
731
625
 
732
626
  @ReactMethod
733
- public void sessionGetTotalVisits(Callback callback) {
627
+ public void getString(String key, Callback callback) {
734
628
  String error = null;
735
- int result = -1;
629
+ String result = null;
736
630
 
737
- CleverTapAPI clevertap = getCleverTapAPI();
738
- if (clevertap != null) {
739
- result = clevertap.getTotalVisits();
631
+ CleverTapAPI cleverTap = getCleverTapAPI();
632
+ if (cleverTap != null) {
633
+ CTProductConfigController productConfigController = cleverTap.productConfig();
634
+ if (productConfigController != null) {
635
+ result = productConfigController.getString(key);
636
+ } else {
637
+ error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
638
+ }
740
639
  } else {
741
- error = "CleverTap not initialized";
640
+ error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
742
641
  }
743
642
  callbackWithErrorAndResult(callback, error, result);
744
643
  }
745
644
 
746
645
  @ReactMethod
747
- public void sessionGetScreenCount(Callback callback) {
748
- String error = null;
749
- int result = -1;
646
+ public void getUnreadInboxMessages(Callback callback) {
750
647
 
751
- CleverTapAPI clevertap = getCleverTapAPI();
752
- if (clevertap != null) {
753
- result = clevertap.getScreenCount();
754
- } else {
755
- error = "CleverTap not initialized";
756
- }
757
- callbackWithErrorAndResult(callback, error, result);
648
+ getInboxMessages(callback, InBoxMessages.UNREAD);
758
649
  }
759
650
 
760
- @ReactMethod
761
- public void sessionGetPreviousVisitTime(Callback callback) {
762
- String error = null;
763
- int result = -1;
764
-
765
- CleverTapAPI clevertap = getCleverTapAPI();
766
- if (clevertap != null) {
767
- result = clevertap.getPreviousVisitTime();
768
- } else {
769
- error = "CleverTap not initialized";
770
- }
771
- callbackWithErrorAndResult(callback, error, result);
651
+ //Inbox Callbacks
652
+ public void inboxDidInitialize() {
653
+ WritableMap params = Arguments.createMap();
654
+ sendEvent(CLEVERTAP_INBOX_DID_INITIALIZE, params);//passing empty map
772
655
  }
773
656
 
774
- @ReactMethod
775
- public void sessionGetUTMDetails(Callback callback) {
776
- String error = null;
777
- WritableMap result = null;
778
-
779
- CleverTapAPI clevertap = getCleverTapAPI();
780
- if (clevertap != null) {
781
- UTMDetail details = clevertap.getUTMDetails();
782
- result = utmDetailsToWritableMap(details);
783
- } else {
784
- error = "CleverTap not initialized";
785
- }
786
- callbackWithErrorAndResult(callback, error, result);
657
+ public void inboxMessagesDidUpdate() {
658
+ WritableMap params = Arguments.createMap();
659
+ sendEvent(CLEVERTAP_INBOX_MESSAGES_DID_UPDATE, params); //passing empty map
787
660
  }
788
661
 
789
662
  //App Inbox methods
@@ -797,580 +670,478 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
797
670
  }
798
671
 
799
672
  @ReactMethod
800
- public void showInbox(ReadableMap styleConfig) {
801
- CTInboxStyleConfig inboxStyleConfig = styleConfigFromReadableMap(styleConfig);
673
+ public void markReadInboxMessageForId(String messageId) {
802
674
  CleverTapAPI cleverTap = getCleverTapAPI();
803
675
  if (cleverTap != null) {
804
- cleverTap.showAppInbox(inboxStyleConfig);
676
+ cleverTap.markReadInboxMessage(messageId);
677
+ } else {
678
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
805
679
  }
806
680
  }
807
681
 
808
- @ReactMethod
809
- public void getInboxMessageCount(Callback callback) {
682
+ @Override
683
+ public void onActivated() {
684
+ WritableMap params = Arguments.createMap();
685
+ sendEvent(CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE, params);//passing empty map
686
+ }
810
687
 
811
- String error = null;
812
- int result = -1;
688
+ public void onDismissed(Map<String, Object> var1, @Nullable Map<String, Object> var2) {
813
689
 
814
- CleverTapAPI cleverTap = getCleverTapAPI();
815
- if (cleverTap != null) {
816
- result = cleverTap.getInboxMessageCount();
817
- } else {
818
- error = "CleverTap not initialized";
819
- }
820
- callbackWithErrorAndResult(callback, error, result);
821
- }
690
+ WritableMap extrasParams = getWritableMapFromMap(var1);
691
+ WritableMap actionExtrasParams = getWritableMapFromMap(var2);
822
692
 
823
- @ReactMethod
824
- public void getInboxMessageUnreadCount(Callback callback) {
825
- String error = null;
826
- int result = -1;
693
+ WritableMap params = Arguments.createMap();
694
+ params.putMap("extras", extrasParams);
695
+ params.putMap("actionExtras", actionExtrasParams);
827
696
 
828
- CleverTapAPI cleverTap = getCleverTapAPI();
829
- if (cleverTap != null) {
830
- result = cleverTap.getInboxMessageUnreadCount();
831
- } else {
832
- error = "CleverTap not initialized";
833
- }
834
- callbackWithErrorAndResult(callback, error, result);
697
+ sendEvent(CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED, params);
835
698
  }
836
699
 
837
- @ReactMethod
838
- public void getAllInboxMessages(Callback callback) {
700
+ //Native Display callback
701
+ public void onDisplayUnitsLoaded(ArrayList<CleverTapDisplayUnit> units) {
702
+ WritableMap params = Arguments.createMap();
703
+ params.putArray("displayUnits", getWritableArrayFromList(units));
704
+ sendEvent(CLEVERTAP_ON_DISPLAY_UNITS_LOADED, params);
705
+ }
839
706
 
840
- getInboxMessages(callback, InBoxMessages.ALL);
707
+ @Override
708
+ public void onFetched() {
709
+ WritableMap params = Arguments.createMap();
710
+ sendEvent(CLEVERTAP_PRODUCT_CONFIG_DID_FETCH, params);//passing empty map
841
711
  }
842
712
 
843
- @ReactMethod
844
- public void getUnreadInboxMessages(Callback callback) {
713
+ //Native Display methods
845
714
 
846
- getInboxMessages(callback, InBoxMessages.UNREAD);
715
+ //InApp Notification callback
716
+ public void onInAppButtonClick(HashMap<String, String> hashMap) {
717
+ sendEvent(CLEVERTAP_ON_INAPP_BUTTON_CLICK, getWritableMapFromMap(hashMap));
847
718
  }
848
719
 
849
- @ReactMethod
850
- public void getInboxMessageForId(String messageId, Callback callback) {
851
- String error = null;
852
- String result = null;
720
+ public void onInboxButtonClick(HashMap<String, String> payload) {
853
721
 
854
- CleverTapAPI cleverTap = getCleverTapAPI();
855
- if (cleverTap != null) {
856
- CTInboxMessage inboxMessage = cleverTap.getInboxMessageForId(messageId);
722
+ sendEvent(CLEVERTAP_ON_INBOX_BUTTON_CLICK, getWritableMapFromMap(payload));
857
723
 
858
- if (inboxMessage != null && inboxMessage.getData() != null) {
859
- result = inboxMessage.getData().toString();
860
- }
861
- } else {
862
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
863
- }
864
- callbackWithErrorAndResult(callback, error, result);
865
724
  }
866
725
 
867
- @ReactMethod
868
- public void deleteInboxMessageForId(String messageId) {
869
- CleverTapAPI cleverTap = getCleverTapAPI();
870
- if (cleverTap != null) {
871
- cleverTap.deleteInboxMessage(messageId);
872
- } else {
873
- Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
874
- }
726
+ //Product Config Callback
727
+ @Override
728
+ public void onInit() {
729
+ WritableMap params = Arguments.createMap();
730
+ sendEvent(CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE, params);//passing empty map
731
+ }
732
+
733
+ //Push Notification Clicked callback
734
+ @Override
735
+ public void onNotificationClickedPayloadReceived(HashMap<String, Object> payload) {
736
+ sendEvent(CLEVERTAP_PUSH_NOTIFICATION_CLICKED, getWritableMapFromMap(payload));
875
737
  }
876
738
 
877
739
  @ReactMethod
878
- public void markReadInboxMessageForId(String messageId) {
879
- CleverTapAPI cleverTap = getCleverTapAPI();
880
- if (cleverTap != null) {
881
- cleverTap.markReadInboxMessage(messageId);
882
- } else {
883
- Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
740
+ public void onUserLogin(ReadableMap profile) {
741
+ CleverTapAPI clevertap = getCleverTapAPI();
742
+ if (clevertap == null) {
743
+ return;
884
744
  }
745
+
746
+ Map<String, Object> finalProfile = profileFromReadableMap(profile);
747
+ clevertap.onUserLogin(finalProfile);
885
748
  }
886
749
 
887
750
  @ReactMethod
888
- public void pushInboxNotificationViewedEventForId(String messageId) {
889
- CleverTapAPI cleverTap = getCleverTapAPI();
890
- if (cleverTap != null) {
891
- cleverTap.pushInboxNotificationViewedEvent(messageId);
892
- } else {
893
- Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
751
+ public void profileAddMultiValue(String value, String key) {
752
+ CleverTapAPI clevertap = getCleverTapAPI();
753
+ if (clevertap == null) {
754
+ return;
894
755
  }
756
+ clevertap.addMultiValueForKey(key, value);
895
757
  }
896
758
 
897
759
  @ReactMethod
898
- public void pushInboxNotificationClickedEventForId(String messageId) {
899
- CleverTapAPI cleverTap = getCleverTapAPI();
900
- if (cleverTap != null) {
901
- cleverTap.pushInboxNotificationClickedEvent(messageId);
902
- } else {
903
- Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
760
+ public void profileAddMultiValues(ReadableArray values, String key) {
761
+ CleverTapAPI clevertap = getCleverTapAPI();
762
+ if (clevertap == null) {
763
+ return;
904
764
  }
765
+ ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
766
+ clevertap.addMultiValuesForKey(key, finalValues);
905
767
  }
906
768
 
907
- private void getInboxMessages(Callback callback, InBoxMessages type) {
908
- String error = null;
909
- ArrayList<CTInboxMessage> inboxMessages = new ArrayList<>();
910
- WritableArray result = Arguments.createArray();
911
-
912
- CleverTapAPI cleverTap = getCleverTapAPI();
913
- if (cleverTap != null) {
769
+ // SyncListener
770
+ @SuppressWarnings("rawtypes")
771
+ public void profileDataUpdated(JSONObject updates) {
772
+ if (updates == null) {
773
+ return;
774
+ }
914
775
 
915
- if (type == InBoxMessages.ALL) {
916
- inboxMessages = cleverTap.getAllInboxMessages();
917
- } else if (type == InBoxMessages.UNREAD) {
918
- inboxMessages = cleverTap.getUnreadInboxMessages();
919
- }
776
+ WritableMap updateParams = Arguments.createMap();
777
+ Iterator keys = updates.keys();
778
+ while (keys.hasNext()) {
779
+ String key = keys.next().toString();
780
+ try {
781
+ JSONArray arr = updates.getJSONArray(key);
782
+ WritableArray writableArray = Arguments.createArray();
783
+ for (int n = 0; n < arr.length(); n++) {
784
+ JSONObject object = arr.getJSONObject(n);
785
+ writableArray.pushString(object.toString());
786
+ }
787
+ updateParams.putArray(key, writableArray);
920
788
 
921
- for (CTInboxMessage message : inboxMessages) {
922
- if (message != null && message.getData() != null) {
923
- result.pushString(message.getData().toString());
789
+ } catch (Throwable t) {
790
+ try {
791
+ Object value = updates.get(key);
792
+ updateParams.putString(key, value.toString());
793
+ } catch (Throwable t1) {
794
+ Log.e(TAG, t1.getLocalizedMessage());
924
795
  }
925
796
  }
926
- } else {
927
- error = "CleverTap not initialized";
928
797
  }
929
- callbackWithErrorAndResult(callback, error, result);
798
+
799
+ WritableMap params = Arguments.createMap();
800
+ params.putMap("updates", updateParams);
801
+ sendEvent(CLEVERTAP_PROFILE_SYNC, params);
930
802
  }
931
803
 
932
- //Native Display methods
804
+ public void profileDidInitialize(String CleverTapID) {
805
+ if (CleverTapID == null) {
806
+ return;
807
+ }
808
+ WritableMap params = Arguments.createMap();
809
+ params.putString("CleverTapID", CleverTapID);
810
+ sendEvent(CLEVERTAP_PROFILE_DID_INITIALIZE, params);
811
+ }
933
812
 
934
813
  @ReactMethod
935
- public void getAllDisplayUnits(Callback callback) {
814
+ public void profileGetCleverTapAttributionIdentifier(Callback callback) {
936
815
  String error = null;
937
- WritableArray result = Arguments.createArray();
816
+ String result = null;
938
817
 
939
- CleverTapAPI cleverTap = getCleverTapAPI();
940
- if (cleverTap != null) {
941
- result = getWritableArrayFromList(cleverTap.getAllDisplayUnits());
818
+ CleverTapAPI clevertap = getCleverTapAPI();
819
+ if (clevertap != null) {
820
+ result = clevertap.getCleverTapAttributionIdentifier();
942
821
  } else {
943
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
822
+ error = "CleverTap not initialized";
944
823
  }
945
824
  callbackWithErrorAndResult(callback, error, result);
946
825
  }
947
826
 
948
827
  @ReactMethod
949
- public void getDisplayUnitForId(String unitID, Callback callback) {
828
+ public void profileGetCleverTapID(Callback callback) {
950
829
  String error = null;
951
830
  String result = null;
952
831
 
953
- CleverTapAPI cleverTap = getCleverTapAPI();
954
- if (cleverTap != null) {
955
- CleverTapDisplayUnit displayUnit = cleverTap.getDisplayUnitForId(unitID);
956
- if (displayUnit != null && displayUnit.getJsonObject() != null) {
957
- result = displayUnit.getJsonObject().toString();
958
- }
832
+ CleverTapAPI clevertap = getCleverTapAPI();
833
+ if (clevertap != null) {
834
+ result = clevertap.getCleverTapID();
959
835
  } else {
960
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
836
+ error = "CleverTap not initialized";
961
837
  }
962
838
  callbackWithErrorAndResult(callback, error, result);
963
839
  }
964
840
 
965
841
  @ReactMethod
966
- public void pushDisplayUnitViewedEventForID(String unitID) {
967
- CleverTapAPI cleverTap = getCleverTapAPI();
968
- if (cleverTap != null) {
969
- cleverTap.pushDisplayUnitViewedEventForID(unitID);
970
- } else {
971
- Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
972
- }
973
- }
842
+ public void getCleverTapID(final Callback callback) {
843
+ final CleverTapAPI clevertap = getCleverTapAPI();
844
+ if (clevertap != null) {
845
+ clevertap.getCleverTapID(new OnInitCleverTapIDListener() {
846
+ @Override
847
+ public void onInitCleverTapID(final String cleverTapID) {
848
+ // Callback on main thread
849
+ callbackWithErrorAndResult(callback, null, cleverTapID);
850
+ }
974
851
 
975
- @ReactMethod
976
- public void pushDisplayUnitClickedEventForID(String unitID) {
977
- CleverTapAPI cleverTap = getCleverTapAPI();
978
- if (cleverTap != null) {
979
- cleverTap.pushDisplayUnitClickedEventForID(unitID);
852
+ });
980
853
  } else {
981
- Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
854
+ String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
855
+ callbackWithErrorAndResult(callback, error, null);
982
856
  }
983
857
  }
984
858
 
985
-
986
- //Dynamic Variables Methods
987
- @SuppressLint("NewApi")
988
859
  @ReactMethod
989
- public void registerBooleanVariable(String name) {
990
- if (!checkKitkatVersion("registerBooleanVariable"))
991
- return;
992
-
993
- CleverTapAPI cleverTap = getCleverTapAPI();
994
- if (cleverTap != null) {
995
- cleverTap.registerBooleanVariable(name);
996
- } else {
997
- Log.e(TAG, "CleverTap not initialized");
998
- }
999
- }
860
+ public void profileGetProperty(String propertyName, Callback callback) {
861
+ String error = null;
862
+ Object result = null;
1000
863
 
1001
- @SuppressLint("NewApi")
1002
- @ReactMethod
1003
- public void registerDoubleVariable(String name) {
1004
- if (!checkKitkatVersion("registerDoubleVariable"))
1005
- return;
864
+ CleverTapAPI clevertap = getCleverTapAPI();
865
+ if (clevertap != null) {
866
+ Object value = clevertap.getProperty(propertyName);
867
+ // Handle JSONArray for multi-values, otherwise everything should be primitive or String
868
+ if (value instanceof JSONArray) {
869
+ JSONArray valueArray = (JSONArray) value;
870
+ WritableArray writableArray = Arguments.createArray();
871
+ for (int i = 0; i < valueArray.length(); i++) {
872
+ try {
873
+ writableArray.pushString(valueArray.get(i).toString());
874
+ } catch (JSONException e) {
875
+ //no-op
876
+ }
877
+ }
878
+ result = writableArray;
879
+ } else {
880
+ result = value;
881
+ }
1006
882
 
1007
- CleverTapAPI cleverTap = getCleverTapAPI();
1008
- if (cleverTap != null) {
1009
- cleverTap.registerDoubleVariable(name);
1010
883
  } else {
1011
- Log.e(TAG, "CleverTap not initialized");
884
+ error = "CleverTap not initialized";
1012
885
  }
886
+ callbackWithErrorAndResult(callback, error, result);
1013
887
  }
1014
888
 
1015
- @SuppressLint("NewApi")
1016
889
  @ReactMethod
1017
- public void registerIntegerVariable(String name) {
1018
- if (!checkKitkatVersion("registerIntegerVariable"))
890
+ public void profileRemoveMultiValue(String value, String key) {
891
+ CleverTapAPI clevertap = getCleverTapAPI();
892
+ if (clevertap == null) {
1019
893
  return;
1020
-
1021
- CleverTapAPI cleverTap = getCleverTapAPI();
1022
- if (cleverTap != null) {
1023
- cleverTap.registerIntegerVariable(name);
1024
- } else {
1025
- Log.e(TAG, "CleverTap not initialized");
1026
894
  }
895
+ clevertap.removeMultiValueForKey(key, value);
1027
896
  }
1028
897
 
1029
- @SuppressLint("NewApi")
1030
898
  @ReactMethod
1031
- public void registerStringVariable(String name) {
1032
- if (!checkKitkatVersion("registerStringVariable"))
899
+ public void profileRemoveMultiValues(ReadableArray values, String key) {
900
+ CleverTapAPI clevertap = getCleverTapAPI();
901
+ if (clevertap == null) {
1033
902
  return;
1034
-
1035
- CleverTapAPI cleverTap = getCleverTapAPI();
1036
- if (cleverTap != null) {
1037
- cleverTap.registerStringVariable(name);
1038
- } else {
1039
- Log.e(TAG, "CleverTap not initialized");
1040
903
  }
904
+ ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
905
+ clevertap.removeMultiValuesForKey(key, finalValues);
1041
906
  }
1042
907
 
1043
- @SuppressLint("NewApi")
1044
908
  @ReactMethod
1045
- public void registerListOfBooleanVariable(String name) {
1046
- if (!checkKitkatVersion("registerListOfBooleanVariable"))
909
+ public void profileRemoveValueForKey(String key) {
910
+ CleverTapAPI clevertap = getCleverTapAPI();
911
+ if (clevertap == null) {
1047
912
  return;
1048
-
1049
- CleverTapAPI cleverTap = getCleverTapAPI();
1050
- if (cleverTap != null) {
1051
- cleverTap.registerListOfBooleanVariable(name);
1052
- } else {
1053
- Log.e(TAG, "CleverTap not initialized");
1054
913
  }
914
+ clevertap.removeValueForKey(key);
1055
915
  }
1056
916
 
1057
- @SuppressLint("NewApi")
1058
917
  @ReactMethod
1059
- public void registerListOfDoubleVariable(String name) {
1060
- if (!checkKitkatVersion("registerListOfDoubleVariable"))
918
+ public void profileSet(ReadableMap profile) {
919
+ CleverTapAPI clevertap = getCleverTapAPI();
920
+ if (clevertap == null) {
1061
921
  return;
1062
-
1063
- CleverTapAPI cleverTap = getCleverTapAPI();
1064
- if (cleverTap != null) {
1065
- cleverTap.registerListOfDoubleVariable(name);
1066
- } else {
1067
- Log.e(TAG, "CleverTap not initialized");
1068
922
  }
923
+
924
+ Map<String, Object> finalProfile = profileFromReadableMap(profile);
925
+ clevertap.pushProfile(finalProfile);
1069
926
  }
1070
927
 
1071
- @SuppressLint("NewApi")
1072
928
  @ReactMethod
1073
- public void registerListOfIntegerVariable(String name) {
1074
- if (!checkKitkatVersion("registerListOfIntegerVariable"))
929
+ public void profileSetMultiValues(ReadableArray values, String key) {
930
+ CleverTapAPI clevertap = getCleverTapAPI();
931
+ if (clevertap == null) {
1075
932
  return;
1076
-
1077
- CleverTapAPI cleverTap = getCleverTapAPI();
1078
- if (cleverTap != null) {
1079
- cleverTap.registerListOfIntegerVariable(name);
1080
- } else {
1081
- Log.e(TAG, "CleverTap not initialized");
1082
933
  }
934
+ ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
935
+ clevertap.setMultiValuesForKey(key, finalValues);
1083
936
  }
1084
937
 
1085
- @SuppressLint("NewApi")
1086
938
  @ReactMethod
1087
- public void registerListOfStringVariable(String name) {
1088
- if (!checkKitkatVersion("registerListOfStringVariable"))
1089
- return;
1090
-
939
+ public void pushDisplayUnitClickedEventForID(String unitID) {
1091
940
  CleverTapAPI cleverTap = getCleverTapAPI();
1092
941
  if (cleverTap != null) {
1093
- cleverTap.registerListOfStringVariable(name);
942
+ cleverTap.pushDisplayUnitClickedEventForID(unitID);
1094
943
  } else {
1095
- Log.e(TAG, "CleverTap not initialized");
944
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
1096
945
  }
1097
946
  }
1098
947
 
1099
- @SuppressLint("NewApi")
1100
948
  @ReactMethod
1101
- public void registerMapOfBooleanVariable(String name) {
1102
- if (!checkKitkatVersion("registerMapOfBooleanVariable"))
1103
- return;
1104
-
949
+ public void pushDisplayUnitViewedEventForID(String unitID) {
1105
950
  CleverTapAPI cleverTap = getCleverTapAPI();
1106
951
  if (cleverTap != null) {
1107
- cleverTap.registerMapOfBooleanVariable(name);
952
+ cleverTap.pushDisplayUnitViewedEventForID(unitID);
1108
953
  } else {
1109
- Log.e(TAG, "CleverTap not initialized");
954
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
1110
955
  }
1111
956
  }
1112
957
 
1113
- @SuppressLint("NewApi")
1114
958
  @ReactMethod
1115
- public void registerMapOfDoubleVariable(String name) {
1116
- if (!checkKitkatVersion("registerMapOfDoubleVariable"))
1117
- return;
1118
-
959
+ public void pushInboxNotificationClickedEventForId(String messageId) {
1119
960
  CleverTapAPI cleverTap = getCleverTapAPI();
1120
961
  if (cleverTap != null) {
1121
- cleverTap.registerMapOfDoubleVariable(name);
962
+ cleverTap.pushInboxNotificationClickedEvent(messageId);
1122
963
  } else {
1123
- Log.e(TAG, "CleverTap not initialized");
964
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
1124
965
  }
1125
966
  }
1126
967
 
1127
- @SuppressLint("NewApi")
1128
968
  @ReactMethod
1129
- public void registerMapOfIntegerVariable(String name) {
1130
- if (!checkKitkatVersion("registerMapOfIntegerVariable"))
1131
- return;
1132
-
969
+ public void pushInboxNotificationViewedEventForId(String messageId) {
1133
970
  CleverTapAPI cleverTap = getCleverTapAPI();
1134
971
  if (cleverTap != null) {
1135
- cleverTap.registerMapOfIntegerVariable(name);
972
+ cleverTap.pushInboxNotificationViewedEvent(messageId);
1136
973
  } else {
1137
- Log.e(TAG, "CleverTap not initialized");
974
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
1138
975
  }
1139
976
  }
1140
977
 
1141
- @SuppressLint("NewApi")
1142
978
  @ReactMethod
1143
- public void registerMapOfStringVariable(String name) {
1144
- if (!checkKitkatVersion("registerMapOfStringVariable"))
979
+ public void pushInstallReferrer(String source, String medium, String campaign) {
980
+ CleverTapAPI clevertap = getCleverTapAPI();
981
+ if (clevertap == null) {
1145
982
  return;
1146
-
1147
- CleverTapAPI cleverTap = getCleverTapAPI();
1148
- if (cleverTap != null) {
1149
- cleverTap.registerMapOfStringVariable(name);
1150
- } else {
1151
- Log.e(TAG, "CleverTap not initialized");
1152
983
  }
984
+ clevertap.pushInstallReferrer(source, medium, campaign);
1153
985
  }
1154
986
 
1155
- @SuppressLint("NewApi")
1156
987
  @ReactMethod
1157
- public void getBooleanVariable(String name, Boolean defaultValue, Callback callback) {
1158
- if (!checkKitkatVersion("getBooleanVariable"))
988
+ public void recordChargedEvent(ReadableMap details, ReadableArray items) {
989
+ CleverTapAPI clevertap = getCleverTapAPI();
990
+ if (clevertap == null || details == null) {
1159
991
  return;
1160
-
1161
- String error = null;
1162
- Boolean result = null;
1163
-
1164
- CleverTapAPI cleverTap = getCleverTapAPI();
1165
- if (cleverTap != null) {
1166
- result = cleverTap.getBooleanVariable(name, defaultValue);
1167
- } else {
1168
- error = "CleverTap not initialized";
1169
992
  }
1170
- callbackWithErrorAndResult(callback, error, result);
1171
- }
1172
993
 
1173
- @SuppressLint("NewApi")
1174
- @ReactMethod
1175
- public void getDoubleVariable(String name, Double defaultValue, Callback callback) {
1176
- if (!checkKitkatVersion("getDoubleVariable"))
1177
- return;
994
+ HashMap<String, Object> finalDetails = eventPropsFromReadableMap(details, Object.class);
1178
995
 
1179
- String error = null;
1180
- Double result = null;
996
+ ArrayList<HashMap<String, Object>> finalItems = new ArrayList<>();
1181
997
 
1182
- CleverTapAPI cleverTap = getCleverTapAPI();
1183
- if (cleverTap != null) {
1184
- result = cleverTap.getDoubleVariable(name, defaultValue);
1185
- } else {
1186
- error = "CleverTap not initialized";
998
+ if (items != null) {
999
+ for (int i = 0; i < items.size(); i++) {
1000
+ try {
1001
+ HashMap<String, Object> item = eventPropsFromReadableMap(items.getMap(i), Object.class);
1002
+ finalItems.add(item);
1003
+ } catch (Throwable t) {
1004
+ Log.e(TAG, t.getLocalizedMessage());
1005
+ }
1006
+ }
1187
1007
  }
1188
- callbackWithErrorAndResult(callback, error, result);
1189
- }
1190
-
1191
- @SuppressLint("NewApi")
1192
- @ReactMethod
1193
- public void getIntegerVariable(String name, int defaultValue, Callback callback) {
1194
- if (!checkKitkatVersion("getIntegerVariable"))
1195
- return;
1196
-
1197
- String error = null;
1198
- int result = -1;
1199
1008
 
1200
- CleverTapAPI cleverTap = getCleverTapAPI();
1201
- if (cleverTap != null) {
1202
- result = cleverTap.getIntegerVariable(name, defaultValue);
1203
- } else {
1204
- error = "CleverTap not initialized";
1009
+ try {
1010
+ clevertap.pushChargedEvent(finalDetails, finalItems);
1011
+ } catch (Throwable t) {
1012
+ Log.e(TAG, t.getLocalizedMessage());
1205
1013
  }
1206
- callbackWithErrorAndResult(callback, error, result);
1207
1014
  }
1208
1015
 
1209
- @SuppressLint("NewApi")
1210
1016
  @ReactMethod
1211
- public void getStringVariable(String name, String defaultValue, Callback callback) {
1212
- if (!checkKitkatVersion("getStringVariable"))
1017
+ public void recordEvent(String eventName, ReadableMap props) {
1018
+ CleverTapAPI clevertap = getCleverTapAPI();
1019
+ if (clevertap == null) {
1213
1020
  return;
1021
+ }
1214
1022
 
1215
- String error = null;
1216
- String result = null;
1023
+ Map<String, Object> finalProps = eventPropsFromReadableMap(props, Object.class);
1217
1024
 
1218
- CleverTapAPI cleverTap = getCleverTapAPI();
1219
- if (cleverTap != null) {
1220
- result = cleverTap.getStringVariable(name, defaultValue);
1025
+ if (finalProps == null) {
1026
+ clevertap.pushEvent(eventName);
1221
1027
  } else {
1222
- error = "CleverTap not initialized";
1028
+ clevertap.pushEvent(eventName, finalProps);
1223
1029
  }
1224
- callbackWithErrorAndResult(callback, error, result);
1225
1030
  }
1226
1031
 
1227
- @SuppressLint("NewApi")
1228
1032
  @ReactMethod
1229
- public void getListOfBooleanVariable(String name, ReadableArray defaultValue, Callback callback) {
1230
- if (!checkKitkatVersion("getListOfBooleanVariable"))
1033
+ public void recordScreenView(String screenName) {
1034
+ CleverTapAPI clevertap = getCleverTapAPI();
1035
+ if (clevertap == null) {
1231
1036
  return;
1232
-
1233
- String error = null;
1234
- List<Boolean> result = null;
1235
-
1236
- CleverTapAPI cleverTap = getCleverTapAPI();
1237
- if (cleverTap != null) {
1238
- result = cleverTap
1239
- .getListOfBooleanVariable(name, arrayListFromReadableArray(defaultValue, Boolean.class));
1240
- } else {
1241
- error = "CleverTap not initialized";
1242
1037
  }
1243
- callbackWithErrorAndResult(callback, error, writableArrayFromArrayList(result, Boolean.class));
1038
+ try {
1039
+ clevertap.recordScreen(screenName);
1040
+ } catch (NullPointerException npe) {
1041
+ Log.e(TAG, "Something went wrong in native SDK!");
1042
+ npe.printStackTrace();
1043
+ }
1244
1044
  }
1245
1045
 
1246
- @SuppressLint("NewApi")
1247
- @ReactMethod
1248
- public void getListOfDoubleVariable(String name, ReadableArray defaultValue, Callback callback) {
1249
- if (!checkKitkatVersion("getListOfDoubleVariable"))
1250
- return;
1251
-
1252
- String error = null;
1253
- List<Double> result = null;
1046
+ // Product Config methods
1254
1047
 
1255
- CleverTapAPI cleverTap = getCleverTapAPI();
1256
- if (cleverTap != null) {
1257
- result = cleverTap.getListOfDoubleVariable(name, arrayListFromReadableArray(defaultValue, Double.class));
1258
- } else {
1259
- error = "CleverTap not initialized";
1260
- }
1261
- callbackWithErrorAndResult(callback, error, writableArrayFromArrayList(result, Double.class));
1048
+ @ReactMethod
1049
+ public void registerForPush() {
1050
+ // no-op in Android
1051
+ Log.i(TAG, "CleverTap.registerForPush is a no-op in Android");
1262
1052
  }
1263
1053
 
1264
- @SuppressLint("NewApi")
1265
1054
  @ReactMethod
1266
- public void getListOfIntegerVariable(String name, ReadableArray defaultValue, Callback callback) {
1267
- if (!checkKitkatVersion("getListOfIntegerVariable"))
1055
+ public void reset() {
1056
+ CTProductConfigController productConfigController = getCtProductConfigController();
1057
+ if (productConfigController == null) {
1268
1058
  return;
1269
-
1270
- String error = null;
1271
- List<Integer> result = null;
1272
-
1273
- CleverTapAPI cleverTap = getCleverTapAPI();
1274
- if (cleverTap != null) {
1275
- result = cleverTap
1276
- .getListOfIntegerVariable(name, arrayListFromReadableArray(defaultValue, Integer.class));
1277
- } else {
1278
- error = "CleverTap not initialized";
1279
1059
  }
1280
- callbackWithErrorAndResult(callback, error, writableArrayFromArrayList(result, Integer.class));
1060
+
1061
+ productConfigController.reset();
1281
1062
  }
1282
1063
 
1283
- @SuppressLint("NewApi")
1284
- @ReactMethod
1285
- public void getListOfStringVariable(String name, ReadableArray defaultValue, Callback callback) {
1286
- if (!checkKitkatVersion("getListOfStringVariable"))
1287
- return;
1064
+ // Feature Flag methods
1288
1065
 
1066
+ @ReactMethod
1067
+ public void sessionGetPreviousVisitTime(Callback callback) {
1289
1068
  String error = null;
1290
- List<String> result = null;
1069
+ int result = -1;
1291
1070
 
1292
- CleverTapAPI cleverTap = getCleverTapAPI();
1293
- if (cleverTap != null) {
1294
- result = cleverTap.getListOfStringVariable(name, arrayListFromReadableArray(defaultValue, String.class));
1071
+ CleverTapAPI clevertap = getCleverTapAPI();
1072
+ if (clevertap != null) {
1073
+ result = clevertap.getPreviousVisitTime();
1295
1074
  } else {
1296
1075
  error = "CleverTap not initialized";
1297
1076
  }
1298
- callbackWithErrorAndResult(callback, error, writableArrayFromArrayList(result, String.class));
1077
+ callbackWithErrorAndResult(callback, error, result);
1299
1078
  }
1300
1079
 
1301
- @SuppressLint("NewApi")
1302
- @ReactMethod
1303
- public void getMapOfBooleanVariable(String name, ReadableMap defaultValue, Callback callback) {
1304
- if (!checkKitkatVersion("getMapOfBooleanVariable"))
1305
- return;
1080
+ // Developer Options
1306
1081
 
1082
+ @ReactMethod
1083
+ public void sessionGetScreenCount(Callback callback) {
1307
1084
  String error = null;
1308
- Map<String, Boolean> result = null;
1085
+ int result = -1;
1309
1086
 
1310
- CleverTapAPI cleverTap = getCleverTapAPI();
1311
- if (cleverTap != null) {
1312
- result = cleverTap.getMapOfBooleanVariable(name, eventPropsFromReadableMap(defaultValue, Boolean.class));
1087
+ CleverTapAPI clevertap = getCleverTapAPI();
1088
+ if (clevertap != null) {
1089
+ result = clevertap.getScreenCount();
1313
1090
  } else {
1314
1091
  error = "CleverTap not initialized";
1315
1092
  }
1316
- callbackWithErrorAndResult(callback, error, writableMapFromMap(result, Boolean.class));
1093
+ callbackWithErrorAndResult(callback, error, result);
1317
1094
  }
1318
1095
 
1319
- @SuppressLint("NewApi")
1320
- @ReactMethod
1321
- public void getMapOfDoubleVariable(String name, ReadableMap defaultValue, Callback callback) {
1322
- if (!checkKitkatVersion("getMapOfDoubleVariable"))
1323
- return;
1096
+ // private helpers etc
1324
1097
 
1098
+ @ReactMethod
1099
+ public void sessionGetTimeElapsed(Callback callback) {
1325
1100
  String error = null;
1326
- Map<String, Double> result = null;
1101
+ int result = -1;
1327
1102
 
1328
- CleverTapAPI cleverTap = getCleverTapAPI();
1329
- if (cleverTap != null) {
1330
- result = cleverTap.getMapOfDoubleVariable(name, eventPropsFromReadableMap(defaultValue, Double.class));
1103
+ CleverTapAPI clevertap = getCleverTapAPI();
1104
+ if (clevertap != null) {
1105
+ result = clevertap.getTimeElapsed();
1331
1106
  } else {
1332
1107
  error = "CleverTap not initialized";
1333
1108
  }
1334
- callbackWithErrorAndResult(callback, error, writableMapFromMap(result, Double.class));
1109
+ callbackWithErrorAndResult(callback, error, result);
1335
1110
  }
1336
1111
 
1337
- @SuppressLint("NewApi")
1338
1112
  @ReactMethod
1339
- public void getMapOfIntegerVariable(String name, ReadableMap defaultValue, Callback callback) {
1340
- if (!checkKitkatVersion("getMapOfIntegerVariable"))
1341
- return;
1342
-
1113
+ public void sessionGetTotalVisits(Callback callback) {
1343
1114
  String error = null;
1344
- Map<String, Integer> result = null;
1115
+ int result = -1;
1345
1116
 
1346
- CleverTapAPI cleverTap = getCleverTapAPI();
1347
- if (cleverTap != null) {
1348
- result = cleverTap.getMapOfIntegerVariable(name, eventPropsFromReadableMap(defaultValue, Integer.class));
1117
+ CleverTapAPI clevertap = getCleverTapAPI();
1118
+ if (clevertap != null) {
1119
+ result = clevertap.getTotalVisits();
1349
1120
  } else {
1350
1121
  error = "CleverTap not initialized";
1351
1122
  }
1352
- callbackWithErrorAndResult(callback, error, writableMapFromMap(result, Integer.class));
1123
+ callbackWithErrorAndResult(callback, error, result);
1353
1124
  }
1354
1125
 
1355
- @SuppressLint("NewApi")
1356
1126
  @ReactMethod
1357
- public void getMapOfStringVariable(String name, ReadableMap defaultValue, Callback callback) {
1358
- if (!checkKitkatVersion("getMapOfStringVariable"))
1359
- return;
1360
-
1127
+ public void sessionGetUTMDetails(Callback callback) {
1361
1128
  String error = null;
1362
- Map<String, String> result = null;
1129
+ WritableMap result = null;
1363
1130
 
1364
- CleverTapAPI cleverTap = getCleverTapAPI();
1365
- if (cleverTap != null) {
1366
- result = cleverTap.getMapOfStringVariable(name, eventPropsFromReadableMap(defaultValue, String.class));
1131
+ CleverTapAPI clevertap = getCleverTapAPI();
1132
+ if (clevertap != null) {
1133
+ UTMDetail details = clevertap.getUTMDetails();
1134
+ result = utmDetailsToWritableMap(details);
1367
1135
  } else {
1368
1136
  error = "CleverTap not initialized";
1369
1137
  }
1370
- callbackWithErrorAndResult(callback, error, writableMapFromMap(result, String.class));
1138
+ callbackWithErrorAndResult(callback, error, result);
1371
1139
  }
1372
1140
 
1373
- // Product Config methods
1141
+ @ReactMethod
1142
+ public void setDebugLevel(int level) {
1143
+ CleverTapAPI.setDebugLevel(level);
1144
+ }
1374
1145
 
1375
1146
  @ReactMethod
1376
1147
  public void setDefaultsMap(ReadableMap map) {
@@ -1384,180 +1155,125 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1384
1155
  }
1385
1156
 
1386
1157
  @ReactMethod
1387
- public void fetch() {
1388
- CTProductConfigController productConfigController = getCtProductConfigController();
1389
- if (productConfigController == null) {
1158
+ public void setLocation(double latitude, double longitude) {
1159
+ CleverTapAPI clevertap = getCleverTapAPI();
1160
+ if (clevertap == null) {
1390
1161
  return;
1391
1162
  }
1392
-
1393
- productConfigController.fetch();
1163
+ final Location location = new Location("CleverTapReact");
1164
+ location.setLatitude(latitude);
1165
+ location.setLongitude(longitude);
1166
+ clevertap.setLocation(location);
1394
1167
  }
1395
1168
 
1396
1169
  @ReactMethod
1397
- public void fetchWithMinimumFetchIntervalInSeconds(int interval) {
1170
+ public void setMinimumFetchIntervalInSeconds(int interval) {
1398
1171
  CTProductConfigController productConfigController = getCtProductConfigController();
1399
1172
  if (productConfigController == null) {
1400
1173
  return;
1401
1174
  }
1402
1175
 
1403
- productConfigController.fetch(interval);
1176
+ productConfigController.setMinimumFetchIntervalInSeconds(interval);
1404
1177
  }
1405
1178
 
1179
+ //Sets the SDK to offline mode
1406
1180
  @ReactMethod
1407
- public void activate() {
1408
- CTProductConfigController productConfigController = getCtProductConfigController();
1409
- if (productConfigController == null) {
1181
+ public void setOffline(boolean value) {
1182
+ CleverTapAPI clevertap = getCleverTapAPI();
1183
+ if (clevertap == null) {
1410
1184
  return;
1411
1185
  }
1412
-
1413
- productConfigController.activate();
1186
+ clevertap.setOffline(value);
1414
1187
  }
1415
1188
 
1416
1189
  @ReactMethod
1417
- public void fetchAndActivate() {
1418
- CTProductConfigController productConfigController = getCtProductConfigController();
1419
- if (productConfigController == null) {
1190
+ public void setOptOut(boolean value) {
1191
+ CleverTapAPI clevertap = getCleverTapAPI();
1192
+ if (clevertap == null) {
1420
1193
  return;
1421
1194
  }
1422
-
1423
- productConfigController.fetchAndActivate();
1195
+ clevertap.setOptOut(value);
1424
1196
  }
1425
1197
 
1426
1198
  @ReactMethod
1427
- public void setMinimumFetchIntervalInSeconds(int interval) {
1428
- CTProductConfigController productConfigController = getCtProductConfigController();
1429
- if (productConfigController == null) {
1199
+ public void setPushTokenAsString(String token, String type) {
1200
+ CleverTapAPI clevertap = getCleverTapAPI();
1201
+ if (clevertap == null || token == null || type == null) {
1430
1202
  return;
1431
1203
  }
1432
1204
 
1433
- productConfigController.setMinimumFetchIntervalInSeconds(interval);
1434
- }
1435
-
1436
- @ReactMethod
1437
- public void reset() {
1438
- CTProductConfigController productConfigController = getCtProductConfigController();
1439
- if (productConfigController == null) {
1440
- return;
1205
+ switch (type) {
1206
+ case FCM:
1207
+ clevertap.pushFcmRegistrationId(token, true);
1208
+ break;
1209
+ case XPS:
1210
+ clevertap.pushXiaomiRegistrationId(token, true);
1211
+ break;
1212
+ case BPS:
1213
+ clevertap.pushBaiduRegistrationId(token, true);
1214
+ break;
1215
+ case HPS:
1216
+ clevertap.pushHuaweiRegistrationId(token, true);
1217
+ break;
1218
+ default:
1219
+ Log.e(TAG, "Unknown push token type " + type);
1220
+ break;
1441
1221
  }
1442
-
1443
- productConfigController.reset();
1444
1222
  }
1445
1223
 
1446
1224
  @ReactMethod
1447
- public void getString(String key, Callback callback) {
1448
- String error = null;
1449
- String result = null;
1450
-
1225
+ public void showInbox(ReadableMap styleConfig) {
1226
+ CTInboxStyleConfig inboxStyleConfig = styleConfigFromReadableMap(styleConfig);
1451
1227
  CleverTapAPI cleverTap = getCleverTapAPI();
1452
1228
  if (cleverTap != null) {
1453
- CTProductConfigController productConfigController = cleverTap.productConfig();
1454
- if (productConfigController != null) {
1455
- result = productConfigController.getString(key);
1456
- } else {
1457
- error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
1458
- }
1459
- } else {
1460
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
1229
+ cleverTap.showAppInbox(inboxStyleConfig);
1461
1230
  }
1462
- callbackWithErrorAndResult(callback, error, result);
1463
1231
  }
1464
1232
 
1465
- @ReactMethod
1466
- public void getBoolean(String key, Callback callback) {
1467
- String error = null;
1468
- Boolean result = null;
1233
+ // Increment/Decrement Operator
1469
1234
 
1235
+ @ReactMethod
1236
+ public void profileIncrementValueForKey(Double value,String key) {
1470
1237
  CleverTapAPI cleverTap = getCleverTapAPI();
1471
1238
  if (cleverTap != null) {
1472
- CTProductConfigController productConfigController = cleverTap.productConfig();
1473
- if (productConfigController != null) {
1474
- result = productConfigController.getBoolean(key);
1475
- } else {
1476
- error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
1477
- }
1478
- } else {
1479
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
1239
+ cleverTap.incrementValue(key, value);
1480
1240
  }
1481
- callbackWithErrorAndResult(callback, error, result);
1482
1241
  }
1483
1242
 
1484
1243
  @ReactMethod
1485
- public void getDouble(String key, Callback callback) {
1486
- String error = null;
1487
- Double result = null;
1488
-
1244
+ public void profileDecrementValueForKey(Double value,String key) {
1489
1245
  CleverTapAPI cleverTap = getCleverTapAPI();
1490
1246
  if (cleverTap != null) {
1491
- CTProductConfigController productConfigController = cleverTap.productConfig();
1492
- if (productConfigController != null) {
1493
- result = productConfigController.getDouble(key);
1494
- } else {
1495
- error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
1496
- }
1497
- } else {
1498
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
1247
+ cleverTap.decrementValue(key, value);
1499
1248
  }
1500
- callbackWithErrorAndResult(callback, error, result);
1501
1249
  }
1502
1250
 
1503
- @ReactMethod
1504
- public void getLastFetchTimeStampInMillis(Callback callback) {
1505
- String error = null;
1506
- String result = null;
1251
+ // InApp Controls
1507
1252
 
1253
+ @ReactMethod
1254
+ public void suspendInAppNotifications() {
1508
1255
  CleverTapAPI cleverTap = getCleverTapAPI();
1509
1256
  if (cleverTap != null) {
1510
- CTProductConfigController productConfigController = cleverTap.productConfig();
1511
- if (productConfigController != null) {
1512
- result = String.valueOf(productConfigController.getLastFetchTimeStampInMillis());
1513
- } else {
1514
- error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED.getErrorMessage();
1515
- }
1516
- } else {
1517
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
1518
- }
1519
- callbackWithErrorAndResult(callback, error, result);
1520
- }
1521
-
1522
- private CTProductConfigController getCtProductConfigController() {
1523
- CleverTapAPI clevertap = getCleverTapAPI();
1524
- if (clevertap == null) {
1525
- return null;
1257
+ cleverTap.suspendInAppNotifications();
1526
1258
  }
1259
+ }
1527
1260
 
1528
- return clevertap.productConfig();
1529
- }
1530
-
1531
- // Feature Flag methods
1532
-
1533
- @ReactMethod
1534
- public void getFeatureFlag(String name, Boolean defaultValue, Callback callback) {
1535
- String error = null;
1536
- Boolean result = null;
1537
-
1261
+ @ReactMethod
1262
+ public void discardInAppNotifications() {
1538
1263
  CleverTapAPI cleverTap = getCleverTapAPI();
1539
1264
  if (cleverTap != null) {
1540
- CTFeatureFlagsController featureFlagsController = cleverTap.featureFlag();
1541
- if (featureFlagsController != null) {
1542
- result = featureFlagsController.get(name, defaultValue);
1543
- } else {
1544
- error = ErrorMessages.FF_NOT_INITIALIZED.getErrorMessage();
1545
- }
1546
- } else {
1547
- error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
1265
+ cleverTap.discardInAppNotifications();
1548
1266
  }
1549
- callbackWithErrorAndResult(callback, error, result);
1550
1267
  }
1551
1268
 
1552
- // Developer Options
1553
-
1554
1269
  @ReactMethod
1555
- public void setDebugLevel(int level) {
1556
- CleverTapAPI.setDebugLevel(level);
1270
+ public void resumeInAppNotifications() {
1271
+ CleverTapAPI cleverTap = getCleverTapAPI();
1272
+ if (cleverTap != null) {
1273
+ cleverTap.resumeInAppNotifications();
1274
+ }
1557
1275
  }
1558
1276
 
1559
- // private helpers etc
1560
-
1561
1277
  /**
1562
1278
  * result must be primitive, String or com.facebook.react.bridge.WritableArray/WritableMap
1563
1279
  * see https://github.com/facebook/react-native/issues/3101#issuecomment-143954448
@@ -1574,142 +1290,17 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1574
1290
  }
1575
1291
  }
1576
1292
 
1577
- private void sendEvent(String eventName, @Nullable Object params) {
1578
- try {
1579
- this.context
1580
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
1581
- .emit(eventName, params);
1582
- } catch (Throwable t) {
1583
- Log.e(TAG, t.getLocalizedMessage());
1584
- }
1585
- }
1586
-
1587
- private static JSONObject jsonObjectFromReadableMap(ReadableMap readableMap) throws JSONException {
1588
- JSONObject object = new JSONObject();
1589
- ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
1590
- while (iterator.hasNextKey()) {
1591
- String key = iterator.nextKey();
1592
- switch (readableMap.getType(key)) {
1593
- case Null:
1594
- object.put(key, JSONObject.NULL);
1595
- break;
1596
- case Boolean:
1597
- object.put(key, readableMap.getBoolean(key));
1598
- break;
1599
- case Number:
1600
- object.put(key, readableMap.getDouble(key));
1601
- break;
1602
- case String:
1603
- object.put(key, readableMap.getString(key));
1604
- break;
1605
- case Map:
1606
- object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
1607
- break;
1608
- case Array:
1609
- object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
1610
- break;
1611
- }
1612
- }
1613
- return object;
1614
- }
1615
-
1616
- private static JSONArray jsonArrayFromReadableArray(ReadableArray readableArray) throws JSONException {
1617
- JSONArray array = new JSONArray();
1618
- for (int i = 0; i < readableArray.size(); i++) {
1619
- switch (readableArray.getType(i)) {
1620
- case Null:
1621
- break;
1622
- case Boolean:
1623
- array.put(readableArray.getBoolean(i));
1624
- break;
1625
- case Number:
1626
- array.put(readableArray.getDouble(i));
1627
- break;
1628
- case String:
1629
- array.put(readableArray.getString(i));
1630
- break;
1631
- case Map:
1632
- array.put(jsonObjectFromReadableMap(readableArray.getMap(i)));
1633
- break;
1634
- case Array:
1635
- array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
1636
- break;
1637
- }
1638
- }
1639
- return array;
1640
- }
1641
-
1642
- private static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
1643
- ArrayList<String> array = new ArrayList<>();
1644
- for (int i = 0; i < readableArray.size(); i++) {
1645
- switch (readableArray.getType(i)) {
1646
- case Null:
1647
- break;
1648
- case Boolean:
1649
- array.add(String.valueOf(readableArray.getBoolean(i)));
1650
- break;
1651
- case Number:
1652
- array.add(String.valueOf(readableArray.getDouble(i)));
1653
- break;
1654
- case String:
1655
- array.add(readableArray.getString(i));
1656
- break;
1657
- }
1658
- }
1659
- return array;
1660
- }
1661
-
1662
- private static <T> ArrayList<T> arrayListFromReadableArray(ReadableArray readableArray, Class<T> tClass) {
1663
- ArrayList<T> array = new ArrayList<>();
1664
- for (int i = 0; i < readableArray.size(); i++) {
1665
- switch (readableArray.getType(i)) {
1666
- case Null:
1667
- break;
1668
- case Boolean:
1669
- array.add(tClass.cast(readableArray.getBoolean(i)));
1670
- break;
1671
- case Number:
1672
- try {
1673
- array.add(tClass.cast(readableArray.getDouble(i)));
1674
- } catch (Throwable t) {
1675
- try {
1676
- array.add(tClass.cast(readableArray.getInt(i)));
1677
- } catch (Throwable t1) {
1678
- Log.e(TAG, "Unhandled ReadableType.Number from ReadableArray");
1679
- }
1680
- }
1681
- break;
1682
- case String:
1683
- array.add(tClass.cast(readableArray.getString(i)));
1684
- break;
1685
- }
1686
- }
1687
- return array;
1688
- }
1293
+ // Listeners
1689
1294
 
1690
- private static <T> WritableArray writableArrayFromArrayList(List<T> list, Class<T> tClass) {
1691
- WritableArray writableArray = Arguments.createArray();
1692
- if (list != null) {
1693
- for (Object item : list) {
1694
- switch (tClass.getSimpleName()) {
1695
- case "Boolean":
1696
- writableArray.pushBoolean((Boolean) item);
1697
- break;
1698
- case "Double":
1699
- writableArray.pushDouble((Double) item);
1700
- break;
1701
- case "Integer":
1702
- writableArray.pushInt((Integer) item);
1703
- break;
1704
- case "String":
1705
- writableArray.pushString((String) item);
1706
- break;
1707
- }
1708
- }
1295
+ private boolean checkKitkatVersion(String methodName) {
1296
+ if (VERSION.SDK_INT < VERSION_CODES.KITKAT) {
1297
+ Log.e(TAG, "Call requires API level 19 (current min is " + VERSION.SDK_INT + "):" + methodName);
1298
+ return false;
1709
1299
  }
1710
- return writableArray;
1300
+ return true;
1711
1301
  }
1712
1302
 
1303
+ @SuppressWarnings("SameParameterValue")
1713
1304
  private <T> HashMap<String, T> eventPropsFromReadableMap(ReadableMap propsMap, Class<T> tClass) {
1714
1305
  if (propsMap == null) {
1715
1306
  return null;
@@ -1748,6 +1339,95 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1748
1339
  return props;
1749
1340
  }
1750
1341
 
1342
+ private CleverTapAPI getCleverTapAPI() {
1343
+ if (mCleverTap == null) {
1344
+ CleverTapAPI clevertap = CleverTapAPI.getDefaultInstance(this.context);
1345
+ if (clevertap != null) {
1346
+ clevertap.setCTPushNotificationListener(this);
1347
+ clevertap.setInAppNotificationListener(this);
1348
+ clevertap.setSyncListener(this);
1349
+ clevertap.setCTNotificationInboxListener(this);
1350
+ clevertap.setInboxMessageButtonListener(this);
1351
+ clevertap.setInAppNotificationButtonListener(this);
1352
+ clevertap.setDisplayUnitListener(this);
1353
+ clevertap.setCTProductConfigListener(this);
1354
+ clevertap.setCTFeatureFlagsListener(this);
1355
+ clevertap.setLibrary("React-Native");
1356
+ }
1357
+ mCleverTap = clevertap;
1358
+ }
1359
+
1360
+ return mCleverTap;
1361
+ }
1362
+
1363
+ private CTProductConfigController getCtProductConfigController() {
1364
+ CleverTapAPI clevertap = getCleverTapAPI();
1365
+ if (clevertap == null) {
1366
+ return null;
1367
+ }
1368
+
1369
+ return clevertap.productConfig();
1370
+ }
1371
+
1372
+ private void getInboxMessages(Callback callback, InBoxMessages type) {
1373
+ String error = null;
1374
+ ArrayList<CTInboxMessage> inboxMessages = new ArrayList<>();
1375
+ WritableArray result = Arguments.createArray();
1376
+
1377
+ CleverTapAPI cleverTap = getCleverTapAPI();
1378
+ if (cleverTap != null) {
1379
+
1380
+ if (type == InBoxMessages.ALL) {
1381
+ inboxMessages = cleverTap.getAllInboxMessages();
1382
+ } else if (type == InBoxMessages.UNREAD) {
1383
+ inboxMessages = cleverTap.getUnreadInboxMessages();
1384
+ }
1385
+
1386
+ for (CTInboxMessage message : inboxMessages) {
1387
+ if (message != null && message.getData() != null) {
1388
+ result.pushString(message.getData().toString());
1389
+ }
1390
+ }
1391
+ } else {
1392
+ error = "CleverTap not initialized";
1393
+ }
1394
+ callbackWithErrorAndResult(callback, error, result);
1395
+ }
1396
+
1397
+ private WritableArray getWritableArrayFromList(List<CleverTapDisplayUnit> list) {
1398
+ WritableArray writableArray = Arguments.createArray();
1399
+ if (list != null) {
1400
+ for (CleverTapDisplayUnit item : list) {
1401
+ if (item != null && item.getJsonObject() != null) {
1402
+ writableArray.pushString(item.getJsonObject().toString());
1403
+ }
1404
+ }
1405
+ }
1406
+ return writableArray;
1407
+ }
1408
+
1409
+ @SuppressWarnings({"TypeParameterExplicitlyExtendsObject", "rawtypes"})
1410
+ private WritableMap getWritableMapFromMap(Map<String, ? extends Object> var1) {
1411
+ JSONObject extras = var1 != null ? new JSONObject(var1) : new JSONObject();
1412
+ WritableMap extrasParams = Arguments.createMap();
1413
+ Iterator extrasKeys = extras.keys();
1414
+ while (extrasKeys.hasNext()) {
1415
+ String key = null;
1416
+ String value = null;
1417
+ try {
1418
+ key = extrasKeys.next().toString();
1419
+ value = extras.get(key).toString();
1420
+ } catch (Throwable t) {
1421
+ Log.e(TAG, t.getLocalizedMessage());
1422
+ }
1423
+
1424
+ if (key != null && value != null) {
1425
+ extrasParams.putString(key, value);
1426
+ }
1427
+ }
1428
+ return extrasParams;
1429
+ }
1430
+
1751
1431
  private HashMap<String, Object> profileFromReadableMap(ReadableMap profileMap) {
1752
1432
  if (profileMap == null) {
1753
1433
  return null;
@@ -1799,40 +1479,16 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1799
1479
  }
1800
1480
  }
1801
1481
  return profile;
1802
- }
1803
-
1804
- private static WritableMap eventDetailToWritableMap(EventDetail details) {
1805
- WritableMap ret = Arguments.createMap();
1806
-
1807
- if (details != null) {
1808
- ret.putString("name", details.getName());
1809
- ret.putInt("firstTime", details.getFirstTime());
1810
- ret.putInt("lastTime", details.getLastTime());
1811
- ret.putInt("count", details.getCount());
1812
- }
1813
- return ret;
1814
- }
1815
-
1816
- private static WritableMap utmDetailsToWritableMap(UTMDetail details) {
1817
- WritableMap ret = Arguments.createMap();
1818
-
1819
- if (details != null) {
1820
- ret.putString("campaign", details.getCampaign());
1821
- ret.putString("source", details.getSource());
1822
- ret.putString("medium", details.getMedium());
1823
- }
1824
- return ret;
1825
- }
1826
-
1827
- private static WritableMap eventHistoryToWritableMap(Map<String, EventDetail> history) {
1828
- WritableMap ret = Arguments.createMap();
1829
-
1830
- if (history != null) {
1831
- for (String key : history.keySet()) {
1832
- ret.putMap(key, eventDetailToWritableMap(history.get(key)));
1833
- }
1482
+ }
1483
+
1484
+ private void sendEvent(String eventName, @Nullable Object params) {
1485
+ try {
1486
+ this.context
1487
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
1488
+ .emit(eventName, params);
1489
+ } catch (Throwable t) {
1490
+ Log.e(TAG, t.getLocalizedMessage());
1834
1491
  }
1835
- return ret;
1836
1492
  }
1837
1493
 
1838
1494
  private CTInboxStyleConfig styleConfigFromReadableMap(ReadableMap styleConfig) {
@@ -1909,204 +1565,112 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1909
1565
  return ctInboxStyleConfig;
1910
1566
  }
1911
1567
 
1912
- // Listeners
1913
-
1914
- // InAppNotificationListener
1915
- public boolean beforeShow(Map<String, Object> var1) {
1916
- return true;
1917
- }
1918
-
1919
- public void onDismissed(Map<String, Object> var1, @Nullable Map<String, Object> var2) {
1920
-
1921
- WritableMap extrasParams = getWritableMapFromMap(var1);
1922
- WritableMap actionExtrasParams = getWritableMapFromMap(var2);
1923
-
1924
- WritableMap params = Arguments.createMap();
1925
- params.putMap("extras", extrasParams);
1926
- params.putMap("actionExtras", actionExtrasParams);
1927
-
1928
- sendEvent(CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED, params);
1929
- }
1930
-
1931
- private WritableMap getWritableMapFromMap(Map<String, ? extends Object> var1) {
1932
- JSONObject extras = var1 != null ? new JSONObject(var1) : new JSONObject();
1933
- WritableMap extrasParams = Arguments.createMap();
1934
- Iterator extrasKeys = extras.keys();
1935
- while (extrasKeys.hasNext()) {
1936
- String key = null;
1937
- String value = null;
1938
- try {
1939
- key = extrasKeys.next().toString();
1940
- value = extras.get(key).toString();
1941
- } catch (Throwable t) {
1942
- Log.e(TAG, t.getLocalizedMessage());
1943
- }
1944
-
1945
- if (key != null && value != null) {
1946
- extrasParams.putString(key, value);
1568
+ private static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
1569
+ ArrayList<String> array = new ArrayList<>();
1570
+ for (int i = 0; i < readableArray.size(); i++) {
1571
+ switch (readableArray.getType(i)) {
1572
+ case Null:
1573
+ break;
1574
+ case Boolean:
1575
+ array.add(String.valueOf(readableArray.getBoolean(i)));
1576
+ break;
1577
+ case Number:
1578
+ array.add(String.valueOf(readableArray.getDouble(i)));
1579
+ break;
1580
+ case String:
1581
+ array.add(readableArray.getString(i));
1582
+ break;
1947
1583
  }
1948
1584
  }
1949
- return extrasParams;
1585
+ return array;
1950
1586
  }
1951
1587
 
1952
- private <T> WritableMap writableMapFromMap(Map<String, T> var1, Class<T> tClass) {
1953
- JSONObject extras = var1 != null ? new JSONObject(var1) : new JSONObject();
1954
- WritableMap extrasParams = Arguments.createMap();
1955
- Iterator extrasKeys = extras.keys();
1956
- while (extrasKeys.hasNext()) {
1957
- String key;
1958
- try {
1959
- key = extrasKeys.next().toString();
1960
-
1961
- switch (tClass.getSimpleName()) {
1962
- case "Boolean":
1963
- extrasParams.putBoolean(key, extras.getBoolean(key));
1964
- break;
1965
- case "Double":
1966
- extrasParams.putDouble(key, extras.getDouble(key));
1967
- break;
1968
- case "Integer":
1969
- extrasParams.putInt(key, extras.getInt(key));
1970
- break;
1971
- case "String":
1972
- extrasParams.putString(key, extras.getString(key));
1973
- break;
1974
- }
1975
- } catch (Throwable t) {
1976
- Log.e(TAG, t.getLocalizedMessage());
1977
- }
1588
+ private static WritableMap eventDetailToWritableMap(EventDetail details) {
1589
+ WritableMap ret = Arguments.createMap();
1978
1590
 
1591
+ if (details != null) {
1592
+ ret.putString("name", details.getName());
1593
+ ret.putInt("firstTime", details.getFirstTime());
1594
+ ret.putInt("lastTime", details.getLastTime());
1595
+ ret.putInt("count", details.getCount());
1979
1596
  }
1980
- return extrasParams;
1597
+ return ret;
1981
1598
  }
1982
1599
 
1983
- private WritableArray getWritableArrayFromList(List<CleverTapDisplayUnit> list) {
1984
- WritableArray writableArray = Arguments.createArray();
1985
- if (list != null) {
1986
- for (CleverTapDisplayUnit item : list) {
1987
- if (item != null && item.getJsonObject() != null) {
1988
- writableArray.pushString(item.getJsonObject().toString());
1989
- }
1600
+ private static WritableMap eventHistoryToWritableMap(Map<String, EventDetail> history) {
1601
+ WritableMap ret = Arguments.createMap();
1602
+
1603
+ if (history != null) {
1604
+ for (String key : history.keySet()) {
1605
+ ret.putMap(key, eventDetailToWritableMap(history.get(key)));
1990
1606
  }
1991
1607
  }
1992
- return writableArray;
1608
+ return ret;
1993
1609
  }
1994
1610
 
1995
- // SyncListener
1996
- public void profileDataUpdated(JSONObject updates) {
1997
- if (updates == null) {
1998
- return;
1999
- }
2000
-
2001
- WritableMap updateParams = Arguments.createMap();
2002
- Iterator keys = updates.keys();
2003
- while (keys.hasNext()) {
2004
- String key = keys.next().toString();
2005
- try {
2006
- JSONArray arr = updates.getJSONArray(key);
2007
- WritableArray writableArray = Arguments.createArray();
2008
- for (int n = 0; n < arr.length(); n++) {
2009
- JSONObject object = arr.getJSONObject(n);
2010
- writableArray.pushString(object.toString());
2011
- }
2012
- updateParams.putArray(key, writableArray);
2013
-
2014
- } catch (Throwable t) {
2015
- try {
2016
- Object value = updates.get(key);
2017
- updateParams.putString(key, value.toString());
2018
- } catch (Throwable t1) {
2019
- Log.e(TAG, t1.getLocalizedMessage());
2020
- }
1611
+ private static JSONArray jsonArrayFromReadableArray(ReadableArray readableArray) throws JSONException {
1612
+ JSONArray array = new JSONArray();
1613
+ for (int i = 0; i < readableArray.size(); i++) {
1614
+ switch (readableArray.getType(i)) {
1615
+ case Null:
1616
+ break;
1617
+ case Boolean:
1618
+ array.put(readableArray.getBoolean(i));
1619
+ break;
1620
+ case Number:
1621
+ array.put(readableArray.getDouble(i));
1622
+ break;
1623
+ case String:
1624
+ array.put(readableArray.getString(i));
1625
+ break;
1626
+ case Map:
1627
+ array.put(jsonObjectFromReadableMap(readableArray.getMap(i)));
1628
+ break;
1629
+ case Array:
1630
+ array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
1631
+ break;
2021
1632
  }
2022
1633
  }
2023
-
2024
- WritableMap params = Arguments.createMap();
2025
- params.putMap("updates", updateParams);
2026
- sendEvent(CLEVERTAP_PROFILE_SYNC, params);
1634
+ return array;
2027
1635
  }
2028
1636
 
2029
- public void profileDidInitialize(String CleverTapID) {
2030
- if (CleverTapID == null) {
2031
- return;
1637
+ private static JSONObject jsonObjectFromReadableMap(ReadableMap readableMap) throws JSONException {
1638
+ JSONObject object = new JSONObject();
1639
+ ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
1640
+ while (iterator.hasNextKey()) {
1641
+ String key = iterator.nextKey();
1642
+ switch (readableMap.getType(key)) {
1643
+ case Null:
1644
+ object.put(key, JSONObject.NULL);
1645
+ break;
1646
+ case Boolean:
1647
+ object.put(key, readableMap.getBoolean(key));
1648
+ break;
1649
+ case Number:
1650
+ object.put(key, readableMap.getDouble(key));
1651
+ break;
1652
+ case String:
1653
+ object.put(key, readableMap.getString(key));
1654
+ break;
1655
+ case Map:
1656
+ object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
1657
+ break;
1658
+ case Array:
1659
+ object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
1660
+ break;
1661
+ }
2032
1662
  }
2033
- WritableMap params = Arguments.createMap();
2034
- params.putString("CleverTapID", CleverTapID);
2035
- sendEvent(CLEVERTAP_PROFILE_DID_INITIALIZE, params);
2036
- }
2037
-
2038
- //Inbox Callbacks
2039
- public void inboxDidInitialize() {
2040
- WritableMap params = Arguments.createMap();
2041
- sendEvent(CLEVERTAP_INBOX_DID_INITIALIZE, params);//passing empty map
2042
- }
2043
-
2044
- public void inboxMessagesDidUpdate() {
2045
- WritableMap params = Arguments.createMap();
2046
- sendEvent(CLEVERTAP_INBOX_MESSAGES_DID_UPDATE, params); //passing empty map
2047
- }
2048
-
2049
- public void onInboxButtonClick(HashMap<String, String> payload) {
2050
-
2051
- sendEvent(CLEVERTAP_ON_INBOX_BUTTON_CLICK, getWritableMapFromMap(payload));
2052
-
2053
- }
2054
-
2055
- //InApp Notification callback
2056
- public void onInAppButtonClick(HashMap<String, String> hashMap) {
2057
- sendEvent(CLEVERTAP_ON_INAPP_BUTTON_CLICK, getWritableMapFromMap(hashMap));
2058
- }
2059
-
2060
- //Native Display callback
2061
- public void onDisplayUnitsLoaded(ArrayList<CleverTapDisplayUnit> units) {
2062
- WritableMap params = Arguments.createMap();
2063
- params.putArray("displayUnits", getWritableArrayFromList(units));
2064
- sendEvent(CLEVERTAP_ON_DISPLAY_UNITS_LOADED, params);
2065
- }
2066
-
2067
- //Experiments Callback
2068
- public void CTExperimentsUpdated() {
2069
- WritableMap params = Arguments.createMap();
2070
- sendEvent(CLEVERTAP_EXPERIMENTS_DID_UPDATE, params);//passing empty map
2071
- }
2072
-
2073
- //Feature Flags Callback
2074
- @Override
2075
- public void featureFlagsUpdated() {
2076
- WritableMap params = Arguments.createMap();
2077
- sendEvent(CLEVERTAP_FEATURE_FLAGS_DID_UPDATE, params);//passing empty map
2078
- }
2079
-
2080
- //Product Config Callback
2081
- @Override
2082
- public void onInit() {
2083
- WritableMap params = Arguments.createMap();
2084
- sendEvent(CLEVERTAP_PRODUCT_CONFIG_DID_INITIALIZE, params);//passing empty map
2085
- }
2086
-
2087
- @Override
2088
- public void onFetched() {
2089
- WritableMap params = Arguments.createMap();
2090
- sendEvent(CLEVERTAP_PRODUCT_CONFIG_DID_FETCH, params);//passing empty map
2091
- }
2092
-
2093
- @Override
2094
- public void onActivated() {
2095
- WritableMap params = Arguments.createMap();
2096
- sendEvent(CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE, params);//passing empty map
1663
+ return object;
2097
1664
  }
2098
1665
 
2099
- //Push Notification Clicked callback
2100
- @Override
2101
- public void onNotificationClickedPayloadReceived(HashMap<String, Object> payload) {
2102
- sendEvent(CLEVERTAP_PUSH_NOTIFICATION_CLICKED, getWritableMapFromMap(payload));
2103
- }
1666
+ private static WritableMap utmDetailsToWritableMap(UTMDetail details) {
1667
+ WritableMap ret = Arguments.createMap();
2104
1668
 
2105
- private boolean checkKitkatVersion(String methodName) {
2106
- if (VERSION.SDK_INT < VERSION_CODES.KITKAT) {
2107
- Log.e(TAG, "Call requires API level 19 (current min is " + VERSION.SDK_INT + "):" + methodName);
2108
- return false;
1669
+ if (details != null) {
1670
+ ret.putString("campaign", details.getCampaign());
1671
+ ret.putString("source", details.getSource());
1672
+ ret.putString("medium", details.getMedium());
2109
1673
  }
2110
- return true;
1674
+ return ret;
2111
1675
  }
2112
1676
  }