clevertap-react-native 1.0.2 → 1.1.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.
package/index.d.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  export function removeListener(eventName: string): void;
22
22
 
23
23
  /**
24
- * Deprecated - Since version 5.0.0. Use removeListener(eventName) instead
24
+ * @deprecated - Since version 5.0.0. Use removeListener(eventName) instead
25
25
  * Remove all event listeners
26
26
  */
27
27
  export function removeListeners(): void;
@@ -450,6 +450,11 @@ export function isPushPermissionGranted(callback: CallbackString): void;
450
450
  */
451
451
  export function showInbox(styleConfig: any): void;
452
452
 
453
+ /**
454
+ * Call this method to dismiss the App Inbox
455
+ */
456
+ export function dismissInbox(): void;
457
+
453
458
  /**
454
459
  * Call this method to get all inbox messages
455
460
  */
@@ -470,11 +475,21 @@ export function isPushPermissionGranted(callback: CallbackString): void;
470
475
  */
471
476
  export function deleteInboxMessageForId(messageId: string): void;
472
477
 
478
+ /**
479
+ * Call this method to delete multiple inbox messages that belongs to the given message ids
480
+ */
481
+ export function deleteInboxMessagesForIDs(messageIds: any): void;
482
+
473
483
  /**
474
484
  * Call this method to mark inbox message as read
475
485
  */
476
486
  export function markReadInboxMessageForId(messageId: string): void;
477
487
 
488
+ /**
489
+ * Call this method to mark multiple inbox messages as read
490
+ */
491
+ export function markReadInboxMessagesForIDs(messageIds: any): void;
492
+
478
493
  /**
479
494
  * Call this method to push the Notification Clicked event for App Inbox to CleverTap
480
495
  */
@@ -513,44 +528,68 @@ export function isPushPermissionGranted(callback: CallbackString): void;
513
528
  * Product Configs
514
529
  ******************/
515
530
  /**
531
+ * @deprecated
532
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
533
+ *
516
534
  * Sets default product config params using the given object.
517
535
  * @param productConfigMap {any} key-value product config properties. keys are strings and values can be string, double, integer, boolean or json in string format.
518
536
  */
519
537
  export function setDefaultsMap(productConfigMap: any): void;
520
538
 
521
539
  /**
540
+ * @deprecated
541
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
542
+ *
522
543
  * Starts fetching product configs, adhering to the default minimum fetch interval.
523
544
  */
524
545
  export function fetch(): void;
525
546
 
526
547
  /**
548
+ * @deprecated
549
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
550
+ *
527
551
  * Starts fetching product configs, adhering to the default minimum fetch interval.
528
552
  * @param intervalInSecs {number} minimum fetch interval in seconds.
529
553
  */
530
554
  export function fetchWithMinimumIntervalInSeconds(intervalInSecs: number): void;
531
555
 
532
556
  /**
557
+ * @deprecated
558
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
559
+ *
533
560
  * Activates the most recently fetched product configs, so that the fetched key value pairs take effect.
534
561
  */
535
562
  export function activate(): void;
536
563
 
537
564
  /**
565
+ * @deprecated
566
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
567
+ *
538
568
  * Asynchronously fetches and then activates the fetched product configs.
539
569
  */
540
570
  export function fetchAndActivate(): void;
541
571
 
542
572
  /**
573
+ * @deprecated
574
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
575
+ *
543
576
  * Sets the minimum interval in seconds between successive fetch calls.
544
577
  * @param intervalInSecs {number} interval in seconds between successive fetch calls.
545
578
  */
546
579
  export function setMinimumFetchIntervalInSeconds(intervalInSecs: number): void;
547
580
 
548
581
  /**
582
+ * @deprecated
583
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
584
+ *
549
585
  * Deletes all activated, fetched and defaults configs as well as all Product Config settings.
550
586
  */
551
587
  export function resetProductConfig(): void;
552
588
 
553
589
  /**
590
+ * @deprecated
591
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
592
+ *
554
593
  * Returns the product config parameter value for the given key as a String.
555
594
  * @param key {string} - the name of the key
556
595
  * @param callback {Callback} - callback that returns a value of type string if present else blank
@@ -560,6 +599,9 @@ export function isPushPermissionGranted(callback: CallbackString): void;
560
599
  callback: Callback): void;
561
600
 
562
601
  /**
602
+ * @deprecated
603
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
604
+ *
563
605
  * Returns the product config parameter value for the given key as a boolean.
564
606
  * @param key {string} - the name of the key
565
607
  * @param callback {Callback} - callback that returns a value of type boolean if present else false
@@ -569,6 +611,9 @@ export function isPushPermissionGranted(callback: CallbackString): void;
569
611
  callback: Callback): void;
570
612
 
571
613
  /**
614
+ * @deprecated
615
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
616
+ *
572
617
  * Returns the product config parameter value for the given key as a number.
573
618
  * @param key {string} - the name of the key
574
619
  * @param callback {Callback} - callback that returns a value of type number if present else 0
@@ -578,6 +623,9 @@ export function isPushPermissionGranted(callback: CallbackString): void;
578
623
  callback: Callback): void;
579
624
 
580
625
  /**
626
+ * @deprecated
627
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
628
+ *
581
629
  * Returns the last fetched timestamp in millis.
582
630
  * @param callback {Callback} - callback that returns value of timestamp in millis as a string.
583
631
  */
@@ -588,6 +636,9 @@ export function isPushPermissionGranted(callback: CallbackString): void;
588
636
  ******************/
589
637
 
590
638
  /**
639
+ * @deprecated
640
+ * Since version 1.1.0 and will be removed in the future versions of this SDK.
641
+ *
591
642
  * Getter to return the feature flag configured at the dashboard
592
643
  * @param key {string} - the name of the key
593
644
  * @param defaultValue {boolean} - default value of the key, in case we don't find any feature flag with the key.
@@ -641,6 +692,64 @@ export function isPushPermissionGranted(callback: CallbackString): void;
641
692
  */
642
693
  export function setInstanceWithAccountId(accountId: string): void;
643
694
 
695
+ /*******************
696
+ * Product Experiences: Vars
697
+ ******************/
698
+
699
+ /**
700
+ * Uploads variables to the server. Requires Development/Debug build/configuration.
701
+ */
702
+ export function syncVariables(): void;
703
+
704
+ /**
705
+ * Uploads variables to the server.
706
+ *
707
+ * @param isProduction Provide `true` if variables must be sync in Productuon build/configuration.
708
+ */
709
+ export function syncVariablesinProd(isProduction: boolean): void;
710
+
711
+ /**
712
+ * Forces variables to update from the server.
713
+ *
714
+ * @param {function(err, res)} a callback with a boolean flag whether the update was successful.
715
+ */
716
+ export function fetchVariables(callback: Callback): void;
717
+
718
+ /**
719
+ * Create variables.
720
+ *
721
+ * @param {object} variables The JSON Object specifying the varibles to be created.
722
+ */
723
+ export function defineVariables(variables: object): void;
724
+
725
+ /**
726
+ * Get all variables via a JSON object.
727
+ *
728
+ */
729
+ export function getVariables(callback: Callback): void;
730
+
731
+ /**
732
+ * Get a variable or a group for the specified name.
733
+ *
734
+ * @param {string} name - name.
735
+ */
736
+ export function getVariable(name: string, callback: Callback): void;
737
+
738
+ /**
739
+ * Adds a callback to be invoked when variables are initialised with server values. Will be called each time new values are fetched.
740
+ *
741
+ * @param {function} handler The callback to add
742
+ */
743
+ export function onVariablesChanged(handler: Function): void;
744
+
745
+ /**
746
+ * Called when the value of the variable changes.
747
+ *
748
+ * @param {name} string the name of the variable
749
+ * @param {function} handler The callback to add
750
+ */
751
+ export function onValueChanged(name: string, handler: Function): void;
752
+
644
753
  /*******************
645
754
  * Developer Options
646
755
  ******************/
@@ -673,3 +782,5 @@ export function isPushPermissionGranted(callback: CallbackString): void;
673
782
  export const CleverTapProductConfigDidActivate: string;
674
783
  export const CleverTapPushNotificationClicked: string;
675
784
  export const CleverTapPushPermissionResponseReceived: string;
785
+ export const CleverTapOnVariablesChanged: string;
786
+ export const CleverTapOnValueChanged: string;
package/index.js CHANGED
@@ -3,6 +3,15 @@ import { DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-nat
3
3
  const CleverTapReact = NativeModules.CleverTapReact;
4
4
  const EventEmitter = NativeModules.CleverTapReactEventEmitter ? new NativeEventEmitter(NativeModules.CleverTapReactEventEmitter) : DeviceEventEmitter;
5
5
 
6
+ /**
7
+ * Set the CleverTap React-Native library name with current version
8
+ * @param {string} libName - Library name will be "React-Native"
9
+ * @param {int} libVersion - The updated library version. If current version is 1.1.0 then pass as 10100
10
+ */
11
+ const libName = 'React-Native';
12
+ const libVersion = 10100;
13
+ CleverTapReact.setLibrary(libName,libVersion);
14
+
6
15
  function defaultCallback(method, err, res) {
7
16
  if (err) {
8
17
  console.log('CleverTap ' + method + ' default callback error', err);
@@ -49,12 +58,14 @@ var CleverTap = {
49
58
  CleverTapInboxMessageTapped: CleverTapReact.CleverTapInboxMessageTapped,
50
59
  CleverTapDisplayUnitsLoaded: CleverTapReact.CleverTapDisplayUnitsLoaded,
51
60
  CleverTapInAppNotificationButtonTapped: CleverTapReact.CleverTapInAppNotificationButtonTapped,
52
- CleverTapFeatureFlagsDidUpdate: CleverTapReact.CleverTapFeatureFlagsDidUpdate,
53
- CleverTapProductConfigDidInitialize: CleverTapReact.CleverTapProductConfigDidInitialize,
54
- CleverTapProductConfigDidFetch: CleverTapReact.CleverTapProductConfigDidFetch,
55
- CleverTapProductConfigDidActivate: CleverTapReact.CleverTapProductConfigDidActivate,
61
+ CleverTapFeatureFlagsDidUpdate: CleverTapReact.CleverTapFeatureFlagsDidUpdate, // @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
62
+ CleverTapProductConfigDidInitialize: CleverTapReact.CleverTapProductConfigDidInitialize, // @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
63
+ CleverTapProductConfigDidFetch: CleverTapReact.CleverTapProductConfigDidFetch, // @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
64
+ CleverTapProductConfigDidActivate: CleverTapReact.CleverTapProductConfigDidActivate, // @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
56
65
  CleverTapPushNotificationClicked: CleverTapReact.CleverTapPushNotificationClicked,
57
66
  CleverTapPushPermissionResponseReceived: CleverTapReact.CleverTapPushPermissionResponseReceived,
67
+ CleverTapOnVariablesChanged: CleverTapReact.CleverTapOnVariablesChanged,
68
+ CleverTapOnValueChanged: CleverTapReact.CleverTapOnValueChanged,
58
69
 
59
70
  /**
60
71
  * Add a CleverTap event listener
@@ -81,7 +92,7 @@ var CleverTap = {
81
92
  },
82
93
 
83
94
  /**
84
- * Deprecated - Since version 0.5.0. Use removeListener(eventName) instead
95
+ * @deprecated - Since version 0.5.0. Use removeListener(eventName) instead
85
96
  * Remove all event listeners
86
97
  */
87
98
  removeListeners: function () {
@@ -358,7 +369,7 @@ var CleverTap = {
358
369
  },
359
370
 
360
371
  /**
361
- * Deprecated - Since version 0.6.0. Use getCleverTapID(callback) instead
372
+ * @deprecated - Since version 0.6.0. Use getCleverTapID(callback) instead
362
373
  * Get a unique CleverTap identifier suitable for use with install attribution providers
363
374
  * @param {function(err, res)} callback that returns a string res
364
375
  */
@@ -367,7 +378,7 @@ var CleverTap = {
367
378
  },
368
379
 
369
380
  /**
370
- * Deprecated - Since version 0.6.0. Use getCleverTapID(callback) instead
381
+ * @deprecated - Since version 0.6.0. Use getCleverTapID(callback) instead
371
382
  * Get the user profile's CleverTap identifier value
372
383
  * @param {function(err, res)} callback that returns a string res
373
384
  */
@@ -552,6 +563,13 @@ var CleverTap = {
552
563
  CleverTapReact.showInbox(styleConfig);
553
564
  },
554
565
 
566
+ /**
567
+ * Method to dismiss the App Inbox
568
+ */
569
+ dismissInbox: function () {
570
+ CleverTapReact.dismissInbox();
571
+ },
572
+
555
573
  /**
556
574
  * Get the total number of Inbox Messages
557
575
  * @param {function(err, res)} callback that returns a res of count of inbox messages or -1
@@ -600,6 +618,14 @@ var CleverTap = {
600
618
  CleverTapReact.deleteInboxMessageForId(messageId);
601
619
  },
602
620
 
621
+ /**
622
+ * Deletes multiple Inbox Messages that belongs to the given message ids
623
+ * @param {array} messageIds a collection of ids of inbox messages
624
+ */
625
+ deleteInboxMessagesForIDs: function (messageIds) {
626
+ CleverTapReact.deleteInboxMessagesForIDs(messageIds);
627
+ },
628
+
603
629
  /**
604
630
  * Marks Inbox Message that belongs to the given message id as read
605
631
  * @param {string} message id of inbox message of type CTInboxMessage
@@ -608,6 +634,14 @@ var CleverTap = {
608
634
  CleverTapReact.markReadInboxMessageForId(messageId);
609
635
  },
610
636
 
637
+ /**
638
+ * Marks multiple Inbox Messages that belongs to the given message ids as read
639
+ * @param {array} messageIds a collection of ids of inbox messages
640
+ */
641
+ markReadInboxMessagesForIDs: function (messageIds) {
642
+ CleverTapReact.markReadInboxMessagesForIDs(messageIds);
643
+ },
644
+
611
645
  /**
612
646
  * Pushes the Notification Clicked event for App Inbox to CleverTap.
613
647
  * @param {string} message id of inbox message of type CTInboxMessage
@@ -659,6 +693,8 @@ var CleverTap = {
659
693
 
660
694
 
661
695
  /**
696
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
697
+ *
662
698
  * Sets default product config params using the given object.
663
699
  * @param {object} productConfigMap - key-value product config properties. keys are strings and values can be string, double, integer, boolean or json in string format.
664
700
  */
@@ -667,6 +703,8 @@ var CleverTap = {
667
703
  },
668
704
 
669
705
  /**
706
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
707
+ *
670
708
  * Starts fetching product configs, adhering to the default minimum fetch interval.
671
709
  */
672
710
  fetch: function () {
@@ -674,6 +712,8 @@ var CleverTap = {
674
712
  },
675
713
 
676
714
  /**
715
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
716
+ *
677
717
  * Starts fetching product configs, adhering to the specified minimum fetch interval in seconds.
678
718
  * @param {int} intervalInSecs - minimum fetch interval in seconds.
679
719
  */
@@ -682,6 +722,8 @@ var CleverTap = {
682
722
  },
683
723
 
684
724
  /**
725
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
726
+ *
685
727
  * Activates the most recently fetched product configs, so that the fetched key value pairs take effect.
686
728
  */
687
729
  activate: function () {
@@ -689,6 +731,8 @@ var CleverTap = {
689
731
  },
690
732
 
691
733
  /**
734
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
735
+ *
692
736
  * Asynchronously fetches and then activates the fetched product configs.
693
737
  */
694
738
  fetchAndActivate: function () {
@@ -696,6 +740,8 @@ var CleverTap = {
696
740
  },
697
741
 
698
742
  /**
743
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
744
+ *
699
745
  * Sets the minimum interval in seconds between successive fetch calls.
700
746
  * @param {int} intervalInSecs - interval in seconds between successive fetch calls.
701
747
  */
@@ -704,6 +750,8 @@ var CleverTap = {
704
750
  },
705
751
 
706
752
  /**
753
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
754
+ *
707
755
  * Deletes all activated, fetched and defaults configs as well as all Product Config settings.
708
756
  */
709
757
  resetProductConfig: function () {
@@ -711,33 +759,41 @@ var CleverTap = {
711
759
  },
712
760
 
713
761
  /**
714
- * Returns the product config parameter value for the given key as a String.
715
- * @param {string} the property key
716
- * @param {function(err, res)} callback that returns a value of type string if present else blank
717
- */
762
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
763
+ *
764
+ * Returns the product config parameter value for the given key as a String.
765
+ * @param {string} the property key
766
+ * @param {function(err, res)} callback that returns a value of type string if present else blank
767
+ */
718
768
  getProductConfigString: function (key, callback) {
719
769
  callWithCallback('getString', [key], callback);
720
770
  },
721
771
 
722
772
  /**
723
- * Returns the product config parameter value for the given key as a boolean.
724
- * @param {string} the property key
725
- * @param {function(err, res)} callback that returns a value of type boolean if present else false
726
- */
773
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
774
+ *
775
+ * Returns the product config parameter value for the given key as a boolean.
776
+ * @param {string} the property key
777
+ * @param {function(err, res)} callback that returns a value of type boolean if present else false
778
+ */
727
779
  getProductConfigBoolean: function (key, callback) {
728
780
  callWithCallback('getBoolean', [key], callback);
729
781
  },
730
782
 
731
783
  /**
732
- * Returns the product config parameter value for the given key as a number.
733
- * @param {string} the property key
734
- * @param {function(err, res)} callback that returns a value of type number if present else 0
735
- */
784
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
785
+ *
786
+ * Returns the product config parameter value for the given key as a number.
787
+ * @param {string} the property key
788
+ * @param {function(err, res)} callback that returns a value of type number if present else 0
789
+ */
736
790
  getNumber: function (key, callback) {
737
791
  callWithCallback('getDouble', [key], callback);
738
792
  },
739
793
 
740
794
  /**
795
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
796
+ *
741
797
  * Returns the last fetched timestamp in millis.
742
798
  * @param {function(err, res)} callback that returns value of timestamp in millis as a string.
743
799
  */
@@ -746,11 +802,13 @@ var CleverTap = {
746
802
  },
747
803
 
748
804
  /**
749
- * Getter to return the feature flag configured at the dashboard
750
- * @param {string} key of the feature flag
751
- * @param {string} default value of the key, in case we don't find any feature flag with the key.
752
- * @param {function(err, res)} callback that returns a feature flag value of type boolean if present else provided default value
753
- */
805
+ * @deprecated - Since version 1.1.0 and will be removed in the future versions of this SDK.
806
+ *
807
+ * Getter to return the feature flag configured at the dashboard
808
+ * @param {string} key of the feature flag
809
+ * @param {string} default value of the key, in case we don't find any feature flag with the key.
810
+ * @param {function(err, res)} callback that returns a feature flag value of type boolean if present else provided default value
811
+ */
754
812
  getFeatureFlag: function (name, defaultValue, callback) {
755
813
  callWithCallback('getFeatureFlag', [name, defaultValue], callback);
756
814
  },
@@ -812,6 +870,77 @@ var CleverTap = {
812
870
  */
813
871
  setInstanceWithAccountId: function (accountId) {
814
872
  CleverTapReact.setInstanceWithAccountId(accountId);
873
+ },
874
+
875
+ /**
876
+ * Uploads variables to the server. Requires Development/Debug build/configuration.
877
+ */
878
+ syncVariables: function () {
879
+ CleverTapReact.syncVariables();
880
+ },
881
+
882
+ /**
883
+ * Uploads variables to the server.
884
+ *
885
+ * @param {boolean} isProduction Provide `true` if variables must be sync in Productuon build/configuration.
886
+ */
887
+ syncVariablesinProd: function (isProduction) {
888
+ CleverTapReact.syncVariablesinProd(isProduction)
889
+ },
890
+
891
+ /**
892
+ * Forces variables to update from the server.
893
+ *
894
+ */
895
+ fetchVariables: function (callback) {
896
+ callWithCallback('fetchVariables', null, callback);
897
+ },
898
+
899
+ /**
900
+ * Create variables.
901
+ *
902
+ * @param {object} variables The JSON Object specifying the varibles to be created.
903
+ */
904
+ defineVariables: function (variables) {
905
+ CleverTapReact.defineVariables(variables);
906
+ },
907
+
908
+ /**
909
+ * Get a variable or a group for the specified name.
910
+ *
911
+ * @param {string} name - name.
912
+ */
913
+ getVariable: function (name, callback) {
914
+ callWithCallback('getVariable', [name], callback);
915
+ },
916
+
917
+ /**
918
+ * Get all variables via a JSON object.
919
+ *
920
+ */
921
+ getVariables: function (callback) {
922
+ callWithCallback('getVariables', null, callback);
923
+ },
924
+
925
+ /**
926
+ * Adds a callback to be invoked when variables are initialised with server values. Will be called each time new values are fetched.
927
+ *
928
+ * @param {function} handler The callback to add
929
+ */
930
+ onVariablesChanged: function (handler) {
931
+ CleverTapReact.onVariablesChanged();
932
+ this.addListener(CleverTapReact.CleverTapOnVariablesChanged, handler);
933
+ },
934
+
935
+ /**
936
+ * Called when the value of the variable changes.
937
+ *
938
+ * @param {name} string the name of the variable
939
+ * @param {function} handler The callback to add
940
+ */
941
+ onValueChanged: function (name, handler) {
942
+ CleverTapReact.onValueChanged(name);
943
+ this.addListener(CleverTapReact.CleverTapOnValueChanged, handler);
815
944
  }
816
945
  };
817
946
 
@@ -16,6 +16,8 @@ static NSString *const kCleverTapProductConfigDidInitialize = @"CleverTapProduc
16
16
  static NSString *const kCleverTapPushNotificationClicked = @"CleverTapPushNotificationClicked";
17
17
  static NSString *const kCleverTapPushPermissionResponseReceived = @"CleverTapPushPermissionResponseReceived";
18
18
  static NSString *const kCleverTapInAppNotificationShowed = @"CleverTapInAppNotificationShowed";
19
+ static NSString *const kCleverTapOnVariablesChanged = @"CleverTapOnVariablesChanged";
20
+ static NSString *const kCleverTapOnValueChanged = @"CleverTapOnValueChanged";
19
21
  static NSString *const kXPS = @"XPS";
20
22
 
21
23