clevertap-react-native 0.9.4 → 1.0.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 (68) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
  3. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  4. package/android/.gradle/6.1.1/fileContent/fileContent.lock +0 -0
  5. package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
  6. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/6.1.1/fileHashes/resourceHashesCache.bin +0 -0
  8. package/android/.gradle/6.1.1/javaCompile/classAnalysis.bin +0 -0
  9. package/android/.gradle/6.1.1/javaCompile/jarAnalysis.bin +0 -0
  10. package/android/.gradle/6.1.1/javaCompile/javaCompile.lock +0 -0
  11. package/android/.gradle/6.1.1/javaCompile/taskHistory.bin +0 -0
  12. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  13. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  14. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  15. package/android/.gradle/checksums/checksums.lock +0 -0
  16. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  17. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  18. package/android/build/generated/source/buildConfig/debug/com/clevertap/react/BuildConfig.java +12 -0
  19. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +14 -0
  20. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +27 -0
  21. package/android/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
  22. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
  23. package/android/build/intermediates/annotations_typedef_file/debug/typedefs.txt +0 -0
  24. package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
  25. package/android/build/intermediates/compile_symbol_list/debug/R.txt +5732 -0
  26. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  27. package/android/build/intermediates/incremental/debug-mergeNativeLibs/merge-state +0 -0
  28. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
  29. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
  30. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
  31. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -0
  32. package/android/build/intermediates/incremental/packageDebugResources/merger.xml +2 -0
  33. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/BuildConfig.class +0 -0
  34. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapApplication$1$1.class +0 -0
  35. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapApplication$1.class +0 -0
  36. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapApplication.class +0 -0
  37. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$1.class +0 -0
  38. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$2.class +0 -0
  39. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$ErrorMessages.class +0 -0
  40. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$InBoxMessages.class +0 -0
  41. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule.class +0 -0
  42. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapPackage.class +0 -0
  43. package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapUtils.class +0 -0
  44. package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +14 -0
  45. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
  46. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +17 -0
  47. package/android/build/intermediates/merged_java_res/debug/out.jar +0 -0
  48. package/android/build/intermediates/merged_manifests/debug/output.json +27 -0
  49. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +3965 -0
  50. package/android/build/outputs/aar/android-debug.aar +0 -0
  51. package/android/build/outputs/logs/manifest-merger-debug-report.txt +39 -0
  52. package/android/build.gradle +7 -7
  53. package/android/local.properties +8 -0
  54. package/android/src/main/java/com/clevertap/react/CleverTapModule.java +213 -1
  55. package/clevertap-react-native.podspec +1 -1
  56. package/docs/pushprimer.md +97 -0
  57. package/docs/usage.md +4 -0
  58. package/index.d.ts +39 -4
  59. package/index.js +32 -5
  60. package/ios/CleverTapReact/CleverTapReact.h +2 -0
  61. package/ios/CleverTapReact/CleverTapReact.m +110 -0
  62. package/ios/CleverTapReact/CleverTapReactEventEmitter.m +6 -1
  63. package/ios/CleverTapReact/CleverTapReactManager.m +12 -1
  64. package/package.json +1 -1
  65. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  66. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  67. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/xcuserdata/akash.malhotra.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  68. package/ios/CleverTapReact.xcodeproj/xcuserdata/akash.malhotra.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -0,0 +1,39 @@
1
+ -- Merging decision tree log ---
2
+ manifest
3
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
4
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
5
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
6
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
7
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
8
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
9
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
10
+ package
11
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:2:5-34
12
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
13
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
14
+ android:versionName
15
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
16
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
17
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
18
+ android:versionCode
19
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
20
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:1-5:12
21
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
22
+ xmlns:android
23
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:1:11-69
24
+ application
25
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml:3:5-4:19
26
+ uses-sdk
27
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml reason: use-sdk injection requested
28
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
29
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
30
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
31
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
32
+ android:targetSdkVersion
33
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
34
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
35
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
36
+ android:minSdkVersion
37
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
38
+ ADDED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
39
+ INJECTED from /Users/shivam.sharma/Desktop/clevertap-react-native/android/src/main/AndroidManifest.xml
@@ -15,14 +15,14 @@ buildscript {
15
15
  }
16
16
 
17
17
  android {
18
- compileSdkVersion 31
19
- buildToolsVersion '30.0.3'
18
+ compileSdkVersion 33
19
+ buildToolsVersion '33.0.0'
20
20
 
21
21
  defaultConfig {
22
- minSdkVersion 16
23
- targetSdkVersion 31
24
- versionCode 93
25
- versionName "0.9.3"
22
+ minSdkVersion 19
23
+ targetSdkVersion 33
24
+ versionCode 95
25
+ versionName "1.0.0"
26
26
  }
27
27
  buildTypes {
28
28
  release {
@@ -39,7 +39,7 @@ dependencies {
39
39
  maven { url "$rootDir/../node_modules/react-native/android" }
40
40
  }
41
41
 
42
- api 'com.clevertap.android:clevertap-android-sdk:4.6.6'
42
+ api 'com.clevertap.android:clevertap-android-sdk:4.7.2'
43
43
  implementation 'com.android.installreferrer:installreferrer:2.2'
44
44
  //compile 'com.android.support:appcompat-v7:28.0.0'
45
45
  implementation 'com.facebook.react:react-native:+'
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Mon Dec 26 16:37:20 IST 2022
8
+ sdk.dir=/Users/shivam.sharma/Library/Android/sdk
@@ -2,6 +2,7 @@ package com.clevertap.react;
2
2
 
3
3
  import static com.clevertap.react.CleverTapUtils.getWritableMapFromMap;
4
4
 
5
+ import android.annotation.SuppressLint;
5
6
  import android.location.Location;
6
7
  import android.net.Uri;
7
8
  import android.os.Build.VERSION;
@@ -19,12 +20,15 @@ import com.clevertap.android.sdk.InAppNotificationListener;
19
20
  import com.clevertap.android.sdk.InboxMessageButtonListener;
20
21
  import com.clevertap.android.sdk.InboxMessageListener;
21
22
  import com.clevertap.android.sdk.Logger;
23
+ import com.clevertap.android.sdk.PushPermissionResponseListener;
22
24
  import com.clevertap.android.sdk.SyncListener;
23
25
  import com.clevertap.android.sdk.UTMDetail;
24
26
  import com.clevertap.android.sdk.displayunits.DisplayUnitListener;
25
27
  import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
26
28
  import com.clevertap.android.sdk.events.EventDetail;
27
29
  import com.clevertap.android.sdk.featureFlags.CTFeatureFlagsController;
30
+ import com.clevertap.android.sdk.inapp.CTInAppNotification;
31
+ import com.clevertap.android.sdk.inapp.CTLocalInApp;
28
32
  import com.clevertap.android.sdk.inbox.CTInboxMessage;
29
33
  import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
30
34
  import com.clevertap.android.sdk.product_config.CTProductConfigController;
@@ -60,7 +64,7 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
60
64
  InAppNotificationListener, CTInboxListener,
61
65
  InboxMessageButtonListener, InboxMessageListener,
62
66
  InAppNotificationButtonListener, DisplayUnitListener, CTProductConfigListener,
63
- CTFeatureFlagsListener, CTPushNotificationListener {
67
+ CTFeatureFlagsListener, CTPushNotificationListener, PushPermissionResponseListener {
64
68
 
65
69
  @SuppressWarnings("FieldCanBeLocal")
66
70
  private enum InBoxMessages {
@@ -104,6 +108,8 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
104
108
 
105
109
  private static final String CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED = "CleverTapInAppNotificationDismissed";
106
110
 
111
+ private static final String CLEVERTAP_IN_APP_NOTIFICATION_SHOWED = "CleverTapInAppNotificationShowed";
112
+
107
113
  private static final String FCM = "FCM";
108
114
 
109
115
  private static final String XPS = "XPS";
@@ -133,6 +139,8 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
133
139
 
134
140
  private static final String CLEVERTAP_PUSH_NOTIFICATION_CLICKED = "CleverTapPushNotificationClicked";
135
141
 
142
+ private static final String CLEVERTAP_ON_PUSH_PERMISSION_RESPONSE = "CleverTapPushPermissionResponseReceived";
143
+
136
144
  private final ReactApplicationContext context;
137
145
 
138
146
  private CleverTapAPI mCleverTap;
@@ -161,6 +169,17 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
161
169
  return true;
162
170
  }
163
171
 
172
+ @SuppressLint("RestrictedApi")
173
+ @Override
174
+ public void onShow(CTInAppNotification inAppNotification) {
175
+ WritableMap params = Arguments.createMap();
176
+ JSONObject data = inAppNotification.getJsonDescription();
177
+ if (data != null) {
178
+ params.putString("data", data.toString());
179
+ }
180
+ sendEvent(CLEVERTAP_IN_APP_NOTIFICATION_SHOWED, params);
181
+ }
182
+
164
183
  //Custom Push Notification
165
184
  @ReactMethod
166
185
  public void createNotification(ReadableMap extras) {
@@ -282,6 +301,48 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
282
301
  Log.i(TAG, "Notification Channel Group Id " + groupId + " deleted");
283
302
  }
284
303
 
304
+ //Push permission methods
305
+ @ReactMethod
306
+ public void promptForPushPermission(boolean showFallbackSettings) {
307
+ CleverTapAPI cleverTap = getCleverTapAPI();
308
+ if (cleverTap != null) {
309
+ cleverTap.promptForPushPermission(showFallbackSettings);
310
+ } else {
311
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
312
+ }
313
+ }
314
+
315
+ @ReactMethod
316
+ public void promptPushPrimer(ReadableMap localInAppConfig) {
317
+ CleverTapAPI cleverTap = getCleverTapAPI();
318
+ if (cleverTap != null) {
319
+ JSONObject jsonObject = localInAppConfigFromReadableMap(localInAppConfig);
320
+ cleverTap.promptPushPrimer(jsonObject);
321
+ } else {
322
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
323
+ }
324
+ }
325
+
326
+ @ReactMethod
327
+ public void isPushPermissionGranted(final Callback callback) {
328
+ final CleverTapAPI clevertap = getCleverTapAPI();
329
+ if (clevertap != null) {
330
+ boolean isPushPermissionGranted = clevertap.isPushPermissionGranted();
331
+ callbackWithErrorAndResult(callback, null, isPushPermissionGranted);
332
+ } else {
333
+ String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
334
+ callbackWithErrorAndResult(callback, error, null);
335
+ }
336
+ }
337
+
338
+ @Override
339
+ public void onPushPermissionResponse(boolean accepted) {
340
+ Log.i(TAG, "onPushPermissionResponse result: " + accepted);
341
+ WritableMap params = Arguments.createMap();
342
+ params.putBoolean("accepted", accepted);
343
+ sendEvent(CLEVERTAP_ON_PUSH_PERMISSION_RESPONSE, params);
344
+ }
345
+
285
346
  @ReactMethod
286
347
  public void disablePersonalization() {
287
348
  CleverTapAPI clevertap = getCleverTapAPI();
@@ -456,6 +517,7 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
456
517
  constants.put(CLEVERTAP_PROFILE_DID_INITIALIZE, CLEVERTAP_PROFILE_DID_INITIALIZE);
457
518
  constants.put(CLEVERTAP_PROFILE_SYNC, CLEVERTAP_PROFILE_SYNC);
458
519
  constants.put(CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED, CLEVERTAP_IN_APP_NOTIFICATION_DISMISSED);
520
+ constants.put(CLEVERTAP_IN_APP_NOTIFICATION_SHOWED, CLEVERTAP_IN_APP_NOTIFICATION_SHOWED);
459
521
  constants.put(FCM, FCM);
460
522
  constants.put(XPS, XPS);
461
523
  constants.put(BPS, BPS);
@@ -471,6 +533,7 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
471
533
  constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_FETCH, CLEVERTAP_PRODUCT_CONFIG_DID_FETCH);
472
534
  constants.put(CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE, CLEVERTAP_PRODUCT_CONFIG_DID_ACTIVATE);
473
535
  constants.put(CLEVERTAP_PUSH_NOTIFICATION_CLICKED, CLEVERTAP_PUSH_NOTIFICATION_CLICKED);
536
+ constants.put(CLEVERTAP_ON_PUSH_PERMISSION_RESPONSE, CLEVERTAP_ON_PUSH_PERMISSION_RESPONSE);
474
537
  return constants;
475
538
  }
476
539
 
@@ -1374,6 +1437,7 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1374
1437
  }
1375
1438
 
1376
1439
  private void registerListeners(CleverTapAPI clevertap) {
1440
+ clevertap.registerPushPermissionNotificationResponseListener(this);
1377
1441
  clevertap.setCTPushNotificationListener(this);
1378
1442
  clevertap.setInAppNotificationListener(this);
1379
1443
  clevertap.setSyncListener(this);
@@ -1520,6 +1584,154 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1520
1584
  }
1521
1585
  }
1522
1586
 
1587
+ /**
1588
+ * retrieves the localInAppConfig from the given ReadableMap.
1589
+ * @param readableMap - the map config, received from the host application
1590
+ * @return the Json of the localInAppConfig
1591
+ */
1592
+ private JSONObject localInAppConfigFromReadableMap(ReadableMap readableMap) {
1593
+ if (readableMap == null) {
1594
+ return null;
1595
+ }
1596
+ CTLocalInApp.InAppType inAppType = null;
1597
+ String titleText = null, messageText = null, positiveBtnText = null, negativeBtnText = null,
1598
+ backgroundColor = null, btnBorderColor = null, titleTextColor = null, messageTextColor = null,
1599
+ btnTextColor = null, imageUrl = null, btnBackgroundColor = null, btnBorderRadius = null;
1600
+ boolean fallbackToSettings = false, followDeviceOrientation = false;
1601
+
1602
+ ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
1603
+ while (iterator.hasNextKey()) {
1604
+ try {
1605
+ String configKey = iterator.nextKey();
1606
+ ReadableType readableType = readableMap.getType(configKey);
1607
+ if ("inAppType".equals(configKey) && readableType == ReadableType.String) {
1608
+ inAppType = inAppTypeFromString(readableMap.getString(configKey));
1609
+ }
1610
+ if ("titleText".equals(configKey) && readableType == ReadableType.String) {
1611
+ titleText = readableMap.getString(configKey);
1612
+ }
1613
+ if ("messageText".equals(configKey) && readableType == ReadableType.String) {
1614
+ messageText = readableMap.getString(configKey);
1615
+ }
1616
+ if ("followDeviceOrientation".equals(configKey) && readableType == ReadableType.Boolean) {
1617
+ followDeviceOrientation = readableMap.getBoolean(configKey);
1618
+ }
1619
+ if ("positiveBtnText".equals(configKey) && readableType == ReadableType.String) {
1620
+ positiveBtnText = readableMap.getString(configKey);
1621
+ }
1622
+ if ("negativeBtnText".equals(configKey) && readableType == ReadableType.String) {
1623
+ negativeBtnText = readableMap.getString(configKey);
1624
+ }
1625
+ if ("fallbackToSettings".equals(configKey) && readableType == ReadableType.Boolean) {
1626
+ fallbackToSettings = readableMap.getBoolean(configKey);
1627
+ }
1628
+ if ("backgroundColor".equals(configKey) && readableType == ReadableType.String) {
1629
+ backgroundColor = readableMap.getString(configKey);
1630
+ }
1631
+ if ("btnBorderColor".equals(configKey) && readableType == ReadableType.String) {
1632
+ btnBorderColor = readableMap.getString(configKey);
1633
+ }
1634
+ if ("titleTextColor".equals(configKey) && readableType == ReadableType.String) {
1635
+ titleTextColor = readableMap.getString(configKey);
1636
+ }
1637
+ if ("messageTextColor".equals(configKey) && readableType == ReadableType.String) {
1638
+ messageTextColor = readableMap.getString(configKey);
1639
+ }
1640
+ if ("btnTextColor".equals(configKey) && readableType == ReadableType.String) {
1641
+ btnTextColor = readableMap.getString(configKey);
1642
+ }
1643
+ if ("imageUrl".equals(configKey) && readableType == ReadableType.String) {
1644
+ imageUrl = readableMap.getString(configKey);
1645
+ }
1646
+ if ("btnBackgroundColor".equals(configKey) && readableType == ReadableType.String) {
1647
+ btnBackgroundColor = readableMap.getString(configKey);
1648
+ }
1649
+ if ("btnBorderRadius".equals(configKey) && readableType == ReadableType.String) {
1650
+ btnBorderRadius = readableMap.getString(configKey);
1651
+ }
1652
+ } catch (Throwable t) {
1653
+ Log.e(TAG, "invalid parameters in push primer config" + t.getLocalizedMessage());
1654
+ return null;
1655
+ }
1656
+ }
1657
+
1658
+ //creates the builder instance of localInApp with all the required parameters
1659
+ CTLocalInApp.Builder.Builder6 builderWithRequiredParams = getLocalInAppBuilderWithRequiredParam(
1660
+ inAppType, titleText, messageText, followDeviceOrientation, positiveBtnText, negativeBtnText
1661
+ );
1662
+
1663
+ //adds the optional parameters to the builder instance
1664
+ if(backgroundColor != null) {
1665
+ builderWithRequiredParams.setBackgroundColor(backgroundColor);
1666
+ }
1667
+ if(btnBorderColor != null) {
1668
+ builderWithRequiredParams.setBtnBorderColor(btnBorderColor);
1669
+ }
1670
+ if(titleTextColor != null) {
1671
+ builderWithRequiredParams.setTitleTextColor(titleTextColor);
1672
+ }
1673
+ if(messageTextColor != null) {
1674
+ builderWithRequiredParams.setMessageTextColor(messageTextColor);
1675
+ }
1676
+ if(btnTextColor != null) {
1677
+ builderWithRequiredParams.setBtnTextColor(btnTextColor);
1678
+ }
1679
+ if(imageUrl != null) {
1680
+ builderWithRequiredParams.setImageUrl(imageUrl);
1681
+ }
1682
+ if(btnBackgroundColor != null) {
1683
+ builderWithRequiredParams.setBtnBackgroundColor(btnBackgroundColor);
1684
+ }
1685
+ if(btnBorderRadius != null) {
1686
+ builderWithRequiredParams.setBtnBorderRadius(btnBorderRadius);
1687
+ }
1688
+ builderWithRequiredParams.setFallbackToSettings(fallbackToSettings);
1689
+
1690
+ JSONObject localInAppConfig = builderWithRequiredParams.build();
1691
+ Log.i(TAG, "LocalInAppConfig for push primer prompt: " + localInAppConfig);
1692
+ return localInAppConfig;
1693
+ }
1694
+
1695
+ /**
1696
+ * Creates an instance of the {@link CTLocalInApp.Builder.Builder6} with the required parameters.
1697
+ * @return the {@link CTLocalInApp.Builder.Builder6} instance
1698
+ */
1699
+ private CTLocalInApp.Builder.Builder6 getLocalInAppBuilderWithRequiredParam(CTLocalInApp.InAppType inAppType,
1700
+ String titleText,
1701
+ String messageText,
1702
+ boolean followDeviceOrientation,
1703
+ String positiveBtnText,
1704
+ String negativeBtnText) {
1705
+ //throws exception if any of the required parameter is missing
1706
+ if (inAppType == null || titleText == null || messageText == null || positiveBtnText == null
1707
+ || negativeBtnText == null) {
1708
+ throw new IllegalArgumentException("mandatory parameters are missing in push primer config");
1709
+ }
1710
+
1711
+ CTLocalInApp.Builder builder = CTLocalInApp.builder();
1712
+ return builder.setInAppType(inAppType)
1713
+ .setTitleText(titleText)
1714
+ .setMessageText(messageText)
1715
+ .followDeviceOrientation(followDeviceOrientation)
1716
+ .setPositiveBtnText(positiveBtnText)
1717
+ .setNegativeBtnText(negativeBtnText);
1718
+ }
1719
+
1720
+ //returns InAppType type from the given string
1721
+ private CTLocalInApp.InAppType inAppTypeFromString(String inAppType) {
1722
+ if(inAppType == null) {
1723
+ return null;
1724
+ }
1725
+ switch (inAppType) {
1726
+ case "half-interstitial":
1727
+ return CTLocalInApp.InAppType.HALF_INTERSTITIAL;
1728
+ case "alert":
1729
+ return CTLocalInApp.InAppType.ALERT;
1730
+ default:
1731
+ return null;
1732
+ }
1733
+ }
1734
+
1523
1735
  private CTInboxStyleConfig styleConfigFromReadableMap(ReadableMap styleConfig) {
1524
1736
  if (styleConfig == null) {
1525
1737
  return new CTInboxStyleConfig();
@@ -18,6 +18,6 @@ Pod::Spec.new do |s|
18
18
  s.preserve_paths = 'LICENSE.md', 'README.md', 'package.json', 'index.js'
19
19
  s.source_files = 'ios/CleverTapReact/*.{h,m}'
20
20
 
21
- s.dependency 'CleverTap-iOS-SDK', '4.1.5'
21
+ s.dependency 'CleverTap-iOS-SDK', '4.2.0'
22
22
  s.dependency 'React-Core'
23
23
  end
@@ -0,0 +1,97 @@
1
+ ## 🔖 Overview
2
+
3
+ Push Primer allows you to enable runtime push permission for sending notifications from an app.
4
+
5
+ Starting with the v0.9.5 release, CleverTap React Native supports Push primer for push notification runtime permission through local in-app.
6
+
7
+ For Push Primer, minimum supported version for iOS platform is 10.0 while android 13 for the android platform.
8
+
9
+ ### Push Primer using Half-Interstitial local In-app
10
+ ```javascript
11
+ let localInApp = {
12
+ inAppType: 'half-interstitial',
13
+ titleText: 'Get Notified',
14
+ messageText:
15
+ 'Please enable notifications on your device to use Push Notifications.',
16
+ followDeviceOrientation: true,
17
+ positiveBtnText: 'Allow',
18
+ negativeBtnText: 'Cancel',
19
+ backgroundColor: '#FFFFFF',
20
+ btnBorderColor: '#0000FF',
21
+ titleTextColor: '#0000FF',
22
+ messageTextColor: '#000000',
23
+ btnTextColor: '#FFFFFF',
24
+ btnBackgroundColor: '#0000FF',
25
+ btnBorderRadius: '2',
26
+ fallbackToSettings: true,
27
+ };
28
+
29
+ CleverTap.promptPushPrimer(localInApp);
30
+ ```
31
+
32
+ ### Push Primer using Alert local In-app
33
+ ```javascript
34
+ CleverTap.promptPushPrimer({
35
+ inAppType: 'alert',
36
+ titleText: 'Get Notified',
37
+ messageText: 'Enable Notification permission',
38
+ followDeviceOrientation: true,
39
+ positiveBtnText: 'Allow',
40
+ negativeBtnText: 'Cancel',
41
+ fallbackToSettings: true,
42
+ });
43
+ ```
44
+
45
+ ### Prompt the Notification Permission Dialog (without push primer)
46
+ It takes boolean as a parameter. If the value passed is true and permission is denied then we fallback to app’s notification settings. If false then we just give the callback saying permission is denied.
47
+
48
+ ```javascript
49
+ CleverTap.promptForPushPermission(true);
50
+ ```
51
+
52
+ ### Get the Push notification permission status
53
+ Returns the status of the push permission in the callback handler.
54
+
55
+ ```javascript
56
+ CleverTap.isPushPermissionGranted((err, res) => {
57
+ console.log('isPushPermissionGranted', res, err);
58
+ });
59
+ ```
60
+
61
+ ### Description of the localInApp Object passed inside the PromptPushPrimer(localInApp) method
62
+
63
+ Key Name| Parameters | Description | Required
64
+ :---:|:---:|:---:|:---
65
+ `inAppType` | "half-interstitial" or "alert" | Accepts only half-interstitial & alert type to display the local in-app | Required
66
+ `titleText` | String | Sets the title of the local in-app | Required
67
+ `messageText` | String | Sets the subtitle of the local in-app | Required
68
+ `followDeviceOrientation` | true or false | If true then the local InApp is shown for both portrait and landscape. If it sets false then local InApp only displays for portrait mode | Required
69
+ `positiveBtnText` | String | Sets the text of the positive button | Required
70
+ `negativeBtnText` | String | Sets the text of the negative button | Required
71
+ `fallbackToSettings` | true or false | If true and the permission is denied then we fallback to app’s notification settings, if it’s false then we just give the callback saying permission is denied. | Optional
72
+ `backgroundColor` | Accepts Hex color as String | Sets the background color of the local in-app | Optional
73
+ `btnBorderColor` | Accepts Hex color as String | Sets the border color of both positive/negative buttons | Optional
74
+ `titleTextColor` | Accepts Hex color as String | Sets the title color of the local in-app | Optional
75
+ `messageTextColor` | Accepts Hex color as String | Sets the sub-title color of the local in-app | Optional
76
+ `btnTextColor` | Accepts Hex color as String | Sets the color of text for both positive/negative buttons | Optional
77
+ `btnBackgroundColor` | Accepts Hex color as String | Sets the background color for both positive/negative buttons | Optional
78
+ `btnBorderRadius` | String | Sets the radius for both positive/negative buttons. Default radius is “2” if not set | Optional
79
+ `fallbackToSettings` | true or false | If the value passed is true then we fallback to app’s notification settings in case permission is denied. If false then we just give the callback saying permission is denied. | Optional
80
+
81
+
82
+ ### Available Callbacks for Push Primer
83
+ Based on notification permission grant/deny, CleverTap React Native SDK provides a callback with the permission status.
84
+ For this You can register the CleverTapPushPermissionResponseReceived callback:
85
+ ```javascript
86
+ CleverTap.addListener(CleverTap.CleverTapPushPermissionResponseReceived, (e)=>{/*consume the event*/})
87
+ ```
88
+
89
+ To unregister the callback use below:
90
+ ```javascript
91
+ CleverTap.removeListener(CleverTap.CleverTapPushPermissionResponseReceived);
92
+ ```
93
+
94
+
95
+
96
+
97
+
package/docs/usage.md CHANGED
@@ -170,6 +170,10 @@ CleverTap.pushInboxNotificationClickedEventForId('Message Id');
170
170
 
171
171
  -----------
172
172
 
173
+ ## Push primer for notification Permission (Android and iOS)
174
+ Follow the [Push Primer integration doc](pushprimer.md).
175
+
176
+ -----------
173
177
  ## Push Notifications
174
178
 
175
179
  #### Creating Notification Channel
package/index.d.ts CHANGED
@@ -171,6 +171,25 @@
171
171
  */
172
172
  export function createNotification(extras: any): void;
173
173
 
174
+ /**
175
+ * Call this method to prompt the hard permission dialog directly, if the push primer is not required.
176
+ * @param showFallbackSettings : {boolean} - Pass true to show an alert dialog which routes to app's notification settings page.
177
+ */
178
+ export function promptForPushPermission(showFallbackSettings: boolean): void;
179
+
180
+ /**
181
+ * Call this method to prompt the push primer flow.
182
+ * @param localInAppConfig : {any} object
183
+ */
184
+ export function promptPushPrimer(localInAppConfig: any): void;
185
+
186
+ /**
187
+ * Returns true/false based on whether push permission is granted or denied.
188
+ *
189
+ * @param {function(err, res)} non-null callback to retrieve the result
190
+ */
191
+ export function isPushPermissionGranted(callback: CallbackString): void;
192
+
174
193
  /*******************
175
194
  * Events
176
195
  ******************/
@@ -634,7 +653,23 @@
634
653
  type Callback = (err: object, res: object) => void;
635
654
  type CallbackString = (err: object, res: string) => void;
636
655
 
637
- export const FCM : string;
638
- export const XPS : string;
639
- export const BPS : string;
640
- export const HPS : string;
656
+ export const FCM: string;
657
+ export const XPS: string;
658
+ export const BPS: string;
659
+ export const HPS: string;
660
+ export const CleverTapProfileDidInitialize: string;
661
+ export const CleverTapProfileSync: string;
662
+ export const CleverTapInAppNotificationDismissed: string;
663
+ export const CleverTapInAppNotificationShowed: string;
664
+ export const CleverTapInboxDidInitialize: string;
665
+ export const CleverTapInboxMessagesDidUpdate: string;
666
+ export const CleverTapInboxMessageButtonTapped: string;
667
+ export const CleverTapInboxMessageTapped: string;
668
+ export const CleverTapDisplayUnitsLoaded: string;
669
+ export const CleverTapInAppNotificationButtonTapped: string;
670
+ export const CleverTapFeatureFlagsDidUpdate: string;
671
+ export const CleverTapProductConfigDidInitialize: string;
672
+ export const CleverTapProductConfigDidFetch: string;
673
+ export const CleverTapProductConfigDidActivate: string;
674
+ export const CleverTapPushNotificationClicked: string;
675
+ export const CleverTapPushPermissionResponseReceived: string;
package/index.js CHANGED
@@ -38,6 +38,7 @@ var CleverTap = {
38
38
  CleverTapProfileDidInitialize: CleverTapReact.CleverTapProfileDidInitialize,
39
39
  CleverTapProfileSync: CleverTapReact.CleverTapProfileSync,
40
40
  CleverTapInAppNotificationDismissed: CleverTapReact.CleverTapInAppNotificationDismissed,
41
+ CleverTapInAppNotificationShowed: CleverTapReact.CleverTapInAppNotificationShowed,
41
42
  FCM: CleverTapReact.FCM,
42
43
  XPS: CleverTapReact.XPS,
43
44
  BPS: CleverTapReact.BPS,
@@ -45,7 +46,7 @@ var CleverTap = {
45
46
  CleverTapInboxDidInitialize: CleverTapReact.CleverTapInboxDidInitialize,
46
47
  CleverTapInboxMessagesDidUpdate: CleverTapReact.CleverTapInboxMessagesDidUpdate,
47
48
  CleverTapInboxMessageButtonTapped: CleverTapReact.CleverTapInboxMessageButtonTapped,
48
- CleverTapInboxMessageTapped:CleverTapReact.CleverTapInboxMessageTapped,
49
+ CleverTapInboxMessageTapped: CleverTapReact.CleverTapInboxMessageTapped,
49
50
  CleverTapDisplayUnitsLoaded: CleverTapReact.CleverTapDisplayUnitsLoaded,
50
51
  CleverTapInAppNotificationButtonTapped: CleverTapReact.CleverTapInAppNotificationButtonTapped,
51
52
  CleverTapFeatureFlagsDidUpdate: CleverTapReact.CleverTapFeatureFlagsDidUpdate,
@@ -53,6 +54,7 @@ var CleverTap = {
53
54
  CleverTapProductConfigDidFetch: CleverTapReact.CleverTapProductConfigDidFetch,
54
55
  CleverTapProductConfigDidActivate: CleverTapReact.CleverTapProductConfigDidActivate,
55
56
  CleverTapPushNotificationClicked: CleverTapReact.CleverTapPushNotificationClicked,
57
+ CleverTapPushPermissionResponseReceived: CleverTapReact.CleverTapPushPermissionResponseReceived,
56
58
 
57
59
  /**
58
60
  * Add a CleverTap event listener
@@ -110,10 +112,10 @@ var CleverTap = {
110
112
  * @param {string} type - for Android only, specifying the type of push service token. Values can be CleverTap.FCM for Firebase or CleverTap.XPS for Xiaomi or CleverTap.BPS for Baidu or CleverTap.HPS for Huawei,
111
113
  * @param {string} region - for xps only ,to specify the region
112
114
  */
113
- setPushToken: function (token, type,region="") {
115
+ setPushToken: function (token, type, region = "") {
114
116
  console.log(`CleverTap RN | setPushToken | received : token: '${token}' | type:'${type}' | region:'${region}' `)
115
- if(type === CleverTap.XPS){
116
- CleverTapReact.setPushTokenAsStringWithRegion(token, type,region);
117
+ if (type === CleverTap.XPS) {
118
+ CleverTapReact.setPushTokenAsStringWithRegion(token, type, region);
117
119
  }
118
120
  else {
119
121
  CleverTapReact.setPushTokenAsString(token, type);
@@ -205,6 +207,31 @@ var CleverTap = {
205
207
  CleverTapReact.createNotification(extras);
206
208
  },
207
209
 
210
+ /**
211
+ * Method to prompt the hard permission dialog directly, if the push primer is not required.
212
+ * @param {string} showFallbackSettings - If the value is true then SDK shows an alert dialog which routes to app's notification settings page.
213
+ */
214
+ promptForPushPermission: function (showFallbackSettings) {
215
+ CleverTapReact.promptForPushPermission(showFallbackSettings);
216
+ },
217
+
218
+ /**
219
+ * Method to prompt the push primer for android 13 onwards.
220
+ * @param {object} value - key-value belongs to the localInApp properties. Refer documentation for details.
221
+ */
222
+ promptPushPrimer: function (value) {
223
+ CleverTapReact.promptPushPrimer(value);
224
+ },
225
+
226
+ /**
227
+ * Returns true/false based on whether push permission is granted or denied.
228
+ *
229
+ * @param {function(err, res)} non-null callback to retrieve the result
230
+ */
231
+ isPushPermissionGranted: function (callback) {
232
+ callWithCallback('isPushPermissionGranted', null, callback);
233
+ },
234
+
208
235
  /**
209
236
  * Enables tracking opt out for the currently active user.
210
237
  * @param {boolean} value - A boolean for enabling or disabling tracking for current user
@@ -783,7 +810,7 @@ var CleverTap = {
783
810
  *
784
811
  * @param accountId The ID of the account to use when switching instance.
785
812
  */
786
- setInstanceWithAccountId: function(accountId) {
813
+ setInstanceWithAccountId: function (accountId) {
787
814
  CleverTapReact.setInstanceWithAccountId(accountId);
788
815
  }
789
816
  };
@@ -14,6 +14,8 @@ static NSString *const kCleverTapProductConfigDidFetch = @"CleverTapProduc
14
14
  static NSString *const kCleverTapProductConfigDidActivate = @"CleverTapProductConfigDidActivate";
15
15
  static NSString *const kCleverTapProductConfigDidInitialize = @"CleverTapProductConfigDidInitialize";
16
16
  static NSString *const kCleverTapPushNotificationClicked = @"CleverTapPushNotificationClicked";
17
+ static NSString *const kCleverTapPushPermissionResponseReceived = @"CleverTapPushPermissionResponseReceived";
18
+ static NSString *const kCleverTapInAppNotificationShowed = @"CleverTapInAppNotificationShowed";
17
19
  static NSString *const kXPS = @"XPS";
18
20
 
19
21