@didomi/react-native 2.1.0 → 2.3.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 (36) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/reactnativedidomi/DidomiModule.kt +68 -8
  3. package/android/src/main/java/com/reactnativedidomi/EventTypes.kt +1 -0
  4. package/ios/Didomi.m +15 -0
  5. package/ios/RNDidomi.swift +141 -86
  6. package/lib/commonjs/Constants.js +1 -1
  7. package/lib/commonjs/Constants.js.map +1 -1
  8. package/lib/commonjs/CurrentUserStatusTransaction.js +102 -0
  9. package/lib/commonjs/CurrentUserStatusTransaction.js.map +1 -0
  10. package/lib/commonjs/Didomi.js +9 -1
  11. package/lib/commonjs/Didomi.js.map +1 -1
  12. package/lib/commonjs/DidomiListener.js +12 -1
  13. package/lib/commonjs/DidomiListener.js.map +1 -1
  14. package/lib/commonjs/DidomiTypes.js +2 -1
  15. package/lib/commonjs/DidomiTypes.js.map +1 -1
  16. package/lib/module/Constants.js +1 -1
  17. package/lib/module/Constants.js.map +1 -1
  18. package/lib/module/CurrentUserStatusTransaction.js +95 -0
  19. package/lib/module/CurrentUserStatusTransaction.js.map +1 -0
  20. package/lib/module/Didomi.js +9 -1
  21. package/lib/module/Didomi.js.map +1 -1
  22. package/lib/module/DidomiListener.js +12 -1
  23. package/lib/module/DidomiListener.js.map +1 -1
  24. package/lib/module/DidomiTypes.js +2 -1
  25. package/lib/module/DidomiTypes.js.map +1 -1
  26. package/lib/typescript/Constants.d.ts +1 -1
  27. package/lib/typescript/CurrentUserStatusTransaction.d.ts +14 -0
  28. package/lib/typescript/Didomi.d.ts +8 -0
  29. package/lib/typescript/DidomiTypes.d.ts +6 -1
  30. package/package.json +1 -1
  31. package/react-native-didomi.podspec +1 -1
  32. package/src/Constants.ts +1 -1
  33. package/src/CurrentUserStatusTransaction.ts +140 -0
  34. package/src/Didomi.ts +9 -0
  35. package/src/DidomiListener.ts +11 -1
  36. package/src/DidomiTypes.ts +8 -1
@@ -124,5 +124,5 @@ dependencies {
124
124
 
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
126
126
 
127
- implementation "io.didomi.sdk:android:2.2.0"
127
+ implementation "io.didomi.sdk:android:2.6.0"
128
128
  }
@@ -208,6 +208,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
208
208
  /**
209
209
  * Sync finished
210
210
  */
211
+ @Deprecated("Use syncReady instead", replaceWith = ReplaceWith("syncReady()"))
211
212
  override fun syncDone(event: SyncDoneEvent) = prepareEvent(EventTypes.SYNC_DONE.event, event.organizationUserId)
212
213
 
213
214
  /**
@@ -215,6 +216,11 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
215
216
  */
216
217
  override fun syncError(event: SyncErrorEvent) = prepareEvent(EventTypes.SYNC_ERROR.event, event.error)
217
218
 
219
+ /**
220
+ * Sync ready
221
+ */
222
+ override fun syncReady(event: SyncReadyEvent) = prepareSyncReadyEvent(event)
223
+
218
224
  /**
219
225
  * Language updated
220
226
  */
@@ -226,6 +232,8 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
226
232
  override fun languageUpdateFailed(event: LanguageUpdateFailedEvent) = prepareEvent(EventTypes.LANGUAGE_UPDATE_FAILED.event, event.reason)
227
233
  }
228
234
  private val vendorStatusListeners: MutableSet<String> = mutableSetOf()
235
+ private val syncAcknowledgedCallbacks: MutableMap<Int, () -> Boolean> = mutableMapOf()
236
+ private var syncAcknowledgedCallbackIndex = 0
229
237
 
230
238
  override fun getName() = "Didomi"
231
239
 
@@ -637,14 +645,14 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
637
645
  promise: Promise
638
646
  ) {
639
647
  Didomi.getInstance().setUser(
640
- UserAuthWithHashParams(
648
+ userAuthParams = UserAuthWithHashParams(
641
649
  organizationUserId,
642
650
  algorithm,
643
651
  secretId,
644
652
  digest,
645
653
  salt
646
654
  ),
647
- currentActivity as? FragmentActivity
655
+ activity = currentActivity as? FragmentActivity
648
656
  )
649
657
  promise.resolve(0)
650
658
  }
@@ -683,7 +691,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
683
691
  promise: Promise
684
692
  ) {
685
693
  Didomi.getInstance().setUser(
686
- UserAuthWithHashParams(
694
+ userAuthParams = UserAuthWithHashParams(
687
695
  organizationUserId,
688
696
  algorithm,
689
697
  secretId,
@@ -691,7 +699,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
691
699
  salt,
692
700
  expiration.toLong()
693
701
  ),
694
- currentActivity as? FragmentActivity
702
+ activity = currentActivity as? FragmentActivity
695
703
  )
696
704
  promise.resolve(0)
697
705
  }
@@ -724,13 +732,13 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
724
732
  promise: Promise
725
733
  ) {
726
734
  Didomi.getInstance().setUser(
727
- UserAuthWithEncryptionParams(
735
+ userAuthParams = UserAuthWithEncryptionParams(
728
736
  organizationUserId,
729
737
  algorithm,
730
738
  secretId,
731
739
  initializationVector
732
740
  ),
733
- currentActivity as? FragmentActivity
741
+ activity = currentActivity as? FragmentActivity
734
742
  )
735
743
  promise.resolve(0)
736
744
  }
@@ -766,14 +774,14 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
766
774
  promise: Promise
767
775
  ) {
768
776
  Didomi.getInstance().setUser(
769
- UserAuthWithEncryptionParams(
777
+ userAuthParams = UserAuthWithEncryptionParams(
770
778
  organizationUserId,
771
779
  algorithm,
772
780
  secretId,
773
781
  initializationVector,
774
782
  expiration.toLong()
775
783
  ),
776
- currentActivity as? FragmentActivity
784
+ activity = currentActivity as? FragmentActivity
777
785
  )
778
786
  promise.resolve(0)
779
787
  }
@@ -952,10 +960,62 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
952
960
  }
953
961
  }
954
962
 
963
+ @ReactMethod
964
+ fun commitCurrentUserStatusTransaction(
965
+ enabledPurposes: ReadableArray,
966
+ disabledPurposes: ReadableArray,
967
+ enabledVendors: ReadableArray,
968
+ disabledVendors: ReadableArray,
969
+ promise: Promise
970
+ ) {
971
+ val transaction = Didomi.getInstance().openCurrentUserStatusTransaction()
972
+ transaction.enablePurposes(*readableArrayToStringArray(enabledPurposes))
973
+ transaction.disablePurposes(*readableArrayToStringArray(disabledPurposes))
974
+ transaction.enableVendors(*readableArrayToStringArray(enabledVendors))
975
+ transaction.disableVendors(*readableArrayToStringArray(disabledVendors))
976
+ promise.resolve(transaction.commit())
977
+ }
978
+
979
+ @ReactMethod
980
+ fun syncAcknowledged(callbackIndex: Int, promise: Promise) {
981
+ val result = syncAcknowledgedCallbacks[callbackIndex]?.let { it() }
982
+ syncAcknowledgedCallbacks.remove(callbackIndex)
983
+ if (result != null) {
984
+ promise.resolve(result)
985
+ } else {
986
+ promise.reject(java.lang.IllegalStateException("SyncAcknowledged: Native callback not found. The method can be called only once."))
987
+ }
988
+ }
989
+
990
+ @ReactMethod
991
+ fun removeSyncAcknowledgedCallback(callbackIndex: Int, promise: Promise) {
992
+ syncAcknowledgedCallbacks.remove(callbackIndex)
993
+ promise.resolve(0)
994
+ }
995
+
955
996
  private fun prepareEvent(eventName: String, params: Any?) {
956
997
  Log.d("prepareEvent", "Sending $eventName")
957
998
  reactContext
958
999
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
959
1000
  .emit(eventName, params)
960
1001
  }
1002
+
1003
+ private fun prepareSyncReadyEvent(event: SyncReadyEvent) {
1004
+ val eventName = EventTypes.SYNC_READY.event
1005
+ Log.d("prepareEvent", "Sending $eventName")
1006
+ val callbackIndex = syncAcknowledgedCallbackIndex++
1007
+ syncAcknowledgedCallbacks[callbackIndex] = event.syncAcknowledged
1008
+ val params = WritableNativeMap().apply {
1009
+ putBoolean("statusApplied", event.statusApplied)
1010
+ putInt("syncAcknowledgedIndex", callbackIndex)
1011
+ }
1012
+ reactContext
1013
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
1014
+ .emit(eventName, params)
1015
+ }
1016
+
1017
+ // Required to transform from array to variadic.
1018
+ private fun readableArrayToStringArray(readableArray: ReadableArray): Array<String> {
1019
+ return Array(readableArray.size()) { i -> readableArray.getString(i) }
1020
+ }
961
1021
  }
@@ -49,6 +49,7 @@ enum class EventTypes(val event: String) {
49
49
  PREFERENCES_CLICK_SPI_PURPOSE_SAVE_CHOICES("on_preferences_click_spi_purpose_save_choices"),
50
50
  // Sync
51
51
  SYNC_DONE("on_sync_done"),
52
+ SYNC_READY("on_sync_ready"),
52
53
  SYNC_ERROR("on_sync_error"),
53
54
  // Language
54
55
  LANGUAGE_UPDATED("on_language_updated"),
package/ios/Didomi.m CHANGED
@@ -250,6 +250,21 @@ RCT_EXTERN_METHOD(stopListeningToVendorStatus:(NSString *)vendorId
250
250
  resolve:(RCTPromiseResolveBlock)resolve
251
251
  reject:(RCTPromiseRejectBlock)reject)
252
252
 
253
+ RCT_EXTERN_METHOD(commitCurrentUserStatusTransaction:(NSArray<NSString *> *)enabledPurposes
254
+ disabledPurposes:(NSArray<NSString *> *)disabledPurposes
255
+ enabledVendors:(NSArray<NSString *> *)enabledVendors
256
+ disabledVendors:(NSArray<NSString *> *)disabledVendors
257
+ resolve:(RCTPromiseResolveBlock)resolve
258
+ reject:(RCTPromiseRejectBlock)reject)
259
+
260
+ RCT_EXTERN_METHOD(syncAcknowledged:(int)callbackIndex
261
+ resolve:(RCTPromiseResolveBlock)resolve
262
+ reject:(RCTPromiseRejectBlock)reject)
263
+
264
+ RCT_EXTERN_METHOD(removeSyncAcknowledgedCallback:(int)callbackIndex
265
+ resolve:(RCTPromiseResolveBlock)resolve
266
+ reject:(RCTPromiseRejectBlock)reject)
267
+
253
268
  RCT_EXTERN_METHOD(supportedEvents)
254
269
 
255
270
  @end
@@ -7,6 +7,8 @@ class RNDidomi: RCTEventEmitter {
7
7
 
8
8
  var didomiEventListener: EventListener
9
9
  var vendorStatusListeners: Set<String> = Set()
10
+ var syncAcknowledgedCallbacks: Dictionary<Int, (() -> Bool)> = [:]
11
+ private var syncAcknowledgedCallbackIndex: Int = 0
10
12
 
11
13
  override init() {
12
14
  didomiEventListener = EventListener()
@@ -37,16 +39,16 @@ class RNDidomi: RCTEventEmitter {
37
39
 
38
40
  @objc(onReady:reject:)
39
41
  func onReady(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
40
- Didomi.shared.onReady {
41
- self.dispatchEvent(withName: "on_ready_callback", body: nil)
42
+ Didomi.shared.onReady { [weak self] in
43
+ self?.dispatchEvent(withName: "on_ready_callback", body: nil)
42
44
  }
43
45
  resolve(0)
44
46
  }
45
47
 
46
48
  @objc(onError:reject:)
47
49
  func onError(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
48
- Didomi.shared.onError { error in
49
- self.dispatchEvent(withName: "on_error_callback", body: error.descriptionText)
50
+ Didomi.shared.onError { [weak self] error in
51
+ self?.dispatchEvent(withName: "on_error_callback", body: error.descriptionText)
50
52
  }
51
53
  resolve(0)
52
54
  }
@@ -480,10 +482,10 @@ class RNDidomi: RCTEventEmitter {
480
482
  dynamic func listenToVendorStatus(vendorId: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
481
483
  if (!vendorStatusListeners.contains(vendorId)) {
482
484
  vendorStatusListeners.insert(vendorId)
483
- Didomi.shared.addVendorStatusListener(id: vendorId) { vendorStatus in
485
+ Didomi.shared.addVendorStatusListener(id: vendorId) { [weak self] vendorStatus in
484
486
  let encoder = JSONEncoder()
485
487
  let statusJson = try? JSONSerialization.jsonObject(with: encoder.encode(vendorStatus)) as? [String: Any]
486
- self.dispatchEvent(withName: "on_vendor_status_change_\(vendorId)", body: statusJson)
488
+ self?.dispatchEvent(withName: "on_vendor_status_change_\(vendorId)", body: statusJson)
487
489
  }
488
490
  }
489
491
  resolve(0)
@@ -497,6 +499,47 @@ class RNDidomi: RCTEventEmitter {
497
499
  }
498
500
  resolve(0)
499
501
  }
502
+
503
+ @objc(commitCurrentUserStatusTransaction:disabledPurposes:enabledVendors:disabledVendors:resolve:reject:)
504
+ dynamic func commitCurrentUserStatusTransaction(
505
+ enabledPurposes: [String],
506
+ disabledPurposes: [String],
507
+ enabledVendors: [String],
508
+ disabledVendors: [String],
509
+ resolve:RCTPromiseResolveBlock,
510
+ reject:RCTPromiseRejectBlock
511
+ ) {
512
+ let transaction = Didomi.shared.openCurrentUserStatusTransaction()
513
+ transaction.enablePurposes(enabledPurposes)
514
+ transaction.disablePurposes(disabledPurposes)
515
+ transaction.enableVendors(enabledVendors)
516
+ transaction.disableVendors(disabledVendors)
517
+ resolve(transaction.commit())
518
+ }
519
+
520
+ @objc(syncAcknowledged:resolve:reject:)
521
+ dynamic func syncAcknowledged(
522
+ callbackIndex: Int,
523
+ resolve:RCTPromiseResolveBlock,
524
+ reject:RCTPromiseRejectBlock
525
+ ) {
526
+ if let callback = syncAcknowledgedCallbacks[callbackIndex] {
527
+ syncAcknowledgedCallbacks.removeValue(forKey: callbackIndex)
528
+ resolve(callback())
529
+ } else {
530
+ reject("not_found", "SyncAcknowledged: Native callback not found. The method can be called only once.", NSError.init(domain: "Didomi", code: 404))
531
+ }
532
+ }
533
+
534
+ @objc(removeSyncAcknowledgedCallback:resolve:reject:)
535
+ dynamic func removeSyncAcknowledgedCallback(
536
+ callbackIndex: Int,
537
+ resolve:RCTPromiseResolveBlock,
538
+ reject:RCTPromiseRejectBlock
539
+ ) {
540
+ syncAcknowledgedCallbacks.removeValue(forKey: callbackIndex)
541
+ resolve(0)
542
+ }
500
543
  }
501
544
 
502
545
  // MARK: Didomi Specific structs
@@ -571,6 +614,7 @@ extension RNDidomi {
571
614
  "on_preferences_click_spi_purpose_save_choices",
572
615
  // Sync
573
616
  "on_sync_done",
617
+ "on_sync_ready",
574
618
  "on_sync_error",
575
619
  // Language
576
620
  "on_language_updated",
@@ -584,164 +628,175 @@ extension RNDidomi {
584
628
 
585
629
  private func initEventListener() {
586
630
 
587
- didomiEventListener.onConsentChanged = { event in
588
- self.dispatchEvent(withName: "on_consent_changed", body: "")
631
+ didomiEventListener.onConsentChanged = { [weak self] event in
632
+ self?.dispatchEvent(withName: "on_consent_changed", body: "")
589
633
  }
590
634
 
591
- didomiEventListener.onError = { event in
592
- self.dispatchEvent(withName: "on_error", body: event.descriptionText)
635
+ didomiEventListener.onError = { [weak self] event in
636
+ self?.dispatchEvent(withName: "on_error", body: event.descriptionText)
593
637
  }
594
638
 
595
- didomiEventListener.onReady = { event in
596
- self.dispatchEvent(withName: "on_ready", body: "")
639
+ didomiEventListener.onReady = { [weak self] event in
640
+ self?.dispatchEvent(withName: "on_ready", body: "")
597
641
  }
598
642
 
599
- didomiEventListener.onHideNotice = { event in
600
- self.dispatchEvent(withName: "on_hide_notice", body: "")
643
+ didomiEventListener.onHideNotice = { [weak self] event in
644
+ self?.dispatchEvent(withName: "on_hide_notice", body: "")
601
645
  }
602
646
 
603
- didomiEventListener.onShowNotice = { event in
604
- self.dispatchEvent(withName: "on_show_notice", body: "")
647
+ didomiEventListener.onShowNotice = { [weak self] event in
648
+ self?.dispatchEvent(withName: "on_show_notice", body: "")
605
649
  }
606
650
 
607
- didomiEventListener.onNoticeClickAgree = { event in
608
- self.dispatchEvent(withName: "on_notice_click_agree", body: "")
651
+ didomiEventListener.onNoticeClickAgree = { [weak self] event in
652
+ self?.dispatchEvent(withName: "on_notice_click_agree", body: "")
609
653
  }
610
654
 
611
- didomiEventListener.onNoticeClickDisagree = { event in
612
- self.dispatchEvent(withName: "on_notice_click_disagree", body: "")
655
+ didomiEventListener.onNoticeClickDisagree = { [weak self] event in
656
+ self?.dispatchEvent(withName: "on_notice_click_disagree", body: "")
613
657
  }
614
658
 
615
- didomiEventListener.onNoticeClickViewVendors = { event in
616
- self.dispatchEvent(withName: "on_notice_click_view_vendors", body: "")
659
+ didomiEventListener.onNoticeClickViewVendors = { [weak self] event in
660
+ self?.dispatchEvent(withName: "on_notice_click_view_vendors", body: "")
617
661
  }
618
662
 
619
- didomiEventListener.onNoticeClickViewSPIPurposes = { event in
620
- self.dispatchEvent(withName: "on_notice_click_view_spi_purposes", body: "")
663
+ didomiEventListener.onNoticeClickViewSPIPurposes = { [weak self] event in
664
+ self?.dispatchEvent(withName: "on_notice_click_view_spi_purposes", body: "")
621
665
  }
622
666
 
623
- didomiEventListener.onNoticeClickMoreInfo = { event in
624
- self.dispatchEvent(withName: "on_notice_click_more_info", body: "")
667
+ didomiEventListener.onNoticeClickMoreInfo = { [weak self] event in
668
+ self?.dispatchEvent(withName: "on_notice_click_more_info", body: "")
625
669
  }
626
670
 
627
- didomiEventListener.onNoticeClickPrivacyPolicy = { event in
628
- self.dispatchEvent(withName: "on_notice_click_privacy_policy", body: "")
671
+ didomiEventListener.onNoticeClickPrivacyPolicy = { [weak self] event in
672
+ self?.dispatchEvent(withName: "on_notice_click_privacy_policy", body: "")
673
+ }
674
+
675
+ didomiEventListener.onHidePreferences = { [weak self] event in
676
+ self?.dispatchEvent(withName: "on_hide_preferences", body: "")
629
677
  }
630
678
 
631
- didomiEventListener.onHidePreferences = { event in
632
- self.dispatchEvent(withName: "on_hide_preferences", body: "")
679
+ didomiEventListener.onShowPreferences = { [weak self] event in
680
+ self?.dispatchEvent(withName: "on_show_preferences", body: "")
633
681
  }
634
682
 
635
- didomiEventListener.onShowPreferences = { event in
636
- self.dispatchEvent(withName: "on_show_preferences", body: "")
683
+ didomiEventListener.onPreferencesClickViewPurposes = { [weak self] event in
684
+ self?.dispatchEvent(withName: "on_preferences_click_view_purposes", body: "")
637
685
  }
638
686
 
639
- didomiEventListener.onPreferencesClickViewPurposes = { event in
640
- self.dispatchEvent(withName: "on_preferences_click_view_purposes", body: "")
687
+ didomiEventListener.onPreferencesClickViewVendors = { [weak self] event in
688
+ self?.dispatchEvent(withName: "on_preferences_click_view_vendors", body: "")
641
689
  }
642
690
 
643
- didomiEventListener.onPreferencesClickViewVendors = { event in
644
- self.dispatchEvent(withName: "on_preferences_click_view_vendors", body: "")
691
+ didomiEventListener.onPreferencesClickViewSPIPurposes = { [weak self] event in
692
+ self?.dispatchEvent(withName: "on_preferences_click_view_spi_purposes", body: "")
645
693
  }
646
694
 
647
- didomiEventListener.onPreferencesClickViewSPIPurposes = { event in
648
- self.dispatchEvent(withName: "on_preferences_click_view_spi_purposes", body: "")
695
+ didomiEventListener.onPreferencesClickAgreeToAll = { [weak self] event in
696
+ self?.dispatchEvent(withName: "on_preferences_click_agree_to_all", body: "")
649
697
  }
650
698
 
651
- didomiEventListener.onPreferencesClickAgreeToAll = { event in
652
- self.dispatchEvent(withName: "on_preferences_click_agree_to_all", body: "")
699
+ didomiEventListener.onPreferencesClickDisagreeToAll = { [weak self] event in
700
+ self?.dispatchEvent(withName: "on_preferences_click_disagree_to_all", body: "")
653
701
  }
654
702
 
655
- didomiEventListener.onPreferencesClickDisagreeToAll = { event in
656
- self.dispatchEvent(withName: "on_preferences_click_disagree_to_all", body: "")
703
+ didomiEventListener.onPreferencesClickAgreeToAllPurposes = { [weak self] event in
704
+ self?.dispatchEvent(withName: "on_preferences_click_agree_to_all_purposes", body: "")
657
705
  }
658
706
 
659
- didomiEventListener.onPreferencesClickAgreeToAllPurposes = { event in
660
- self.dispatchEvent(withName: "on_preferences_click_agree_to_all_purposes", body: "")
707
+ didomiEventListener.onPreferencesClickDisagreeToAllPurposes = { [weak self] event in
708
+ self?.dispatchEvent(withName: "on_preferences_click_disagree_to_all_purposes", body: "")
661
709
  }
662
710
 
663
- didomiEventListener.onPreferencesClickDisagreeToAllPurposes = { event in
664
- self.dispatchEvent(withName: "on_preferences_click_disagree_to_all_purposes", body: "")
711
+ didomiEventListener.onPreferencesClickResetAllPurposes = { [weak self] event in
712
+ self?.dispatchEvent(withName: "on_preferences_click_reset_all_purposes", body: "")
665
713
  }
666
714
 
667
- didomiEventListener.onPreferencesClickResetAllPurposes = { event in
668
- self.dispatchEvent(withName: "on_preferences_click_reset_all_purposes", body: "")
715
+ didomiEventListener.onPreferencesClickPurposeAgree = { [weak self] event, purposeId in
716
+ self?.dispatchEvent(withName: "on_preferences_click_purpose_agree", body: purposeId)
669
717
  }
670
718
 
671
- didomiEventListener.onPreferencesClickPurposeAgree = { event, purposeId in
672
- self.dispatchEvent(withName: "on_preferences_click_purpose_agree", body: purposeId)
719
+ didomiEventListener.onPreferencesClickPurposeDisagree = { [weak self] event, purposeId in
720
+ self?.dispatchEvent(withName: "on_preferences_click_purpose_disagree", body: purposeId)
673
721
  }
674
722
 
675
- didomiEventListener.onPreferencesClickPurposeDisagree = { event, purposeId in
676
- self.dispatchEvent(withName: "on_preferences_click_purpose_disagree", body: purposeId)
723
+ didomiEventListener.onPreferencesClickCategoryAgree = { [weak self] event, categoryId in
724
+ self?.dispatchEvent(withName: "on_preferences_click_category_agree", body: categoryId)
677
725
  }
678
726
 
679
- didomiEventListener.onPreferencesClickCategoryAgree = { event, categoryId in
680
- self.dispatchEvent(withName: "on_preferences_click_category_agree", body: categoryId)
727
+ didomiEventListener.onPreferencesClickCategoryDisagree = { [weak self] event, categoryId in
728
+ self?.dispatchEvent(withName: "on_preferences_click_category_disagree", body: categoryId)
681
729
  }
682
730
 
683
- didomiEventListener.onPreferencesClickCategoryDisagree = { event, categoryId in
684
- self.dispatchEvent(withName: "on_preferences_click_category_disagree", body: categoryId)
731
+ didomiEventListener.onPreferencesClickSaveChoices = { [weak self] event in
732
+ self?.dispatchEvent(withName: "on_preferences_click_save_choices", body: "")
685
733
  }
686
734
 
687
- didomiEventListener.onPreferencesClickSaveChoices = { event in
688
- self.dispatchEvent(withName: "on_preferences_click_save_choices", body: "")
735
+ didomiEventListener.onPreferencesClickAgreeToAllVendors = { [weak self] event in
736
+ self?.dispatchEvent(withName: "on_preferences_click_agree_to_all_vendors", body: "")
689
737
  }
690
738
 
691
- didomiEventListener.onPreferencesClickAgreeToAllVendors = { event in
692
- self.dispatchEvent(withName: "on_preferences_click_agree_to_all_vendors", body: "")
739
+ didomiEventListener.onPreferencesClickDisagreeToAllVendors = { [weak self] event in
740
+ self?.dispatchEvent(withName: "on_preferences_click_disagree_to_all_vendors", body: "")
693
741
  }
694
742
 
695
- didomiEventListener.onPreferencesClickDisagreeToAllVendors = { event in
696
- self.dispatchEvent(withName: "on_preferences_click_disagree_to_all_vendors", body: "")
743
+ didomiEventListener.onPreferencesClickVendorAgree = { [weak self] event, vendorId in
744
+ self?.dispatchEvent(withName: "on_preferences_click_vendor_agree", body: vendorId)
697
745
  }
698
746
 
699
- didomiEventListener.onPreferencesClickVendorAgree = { event, vendorId in
700
- self.dispatchEvent(withName: "on_preferences_click_vendor_agree", body: vendorId)
747
+ didomiEventListener.onPreferencesClickVendorDisagree = { [weak self] event, vendorId in
748
+ self?.dispatchEvent(withName: "on_preferences_click_vendor_disagree", body: vendorId)
701
749
  }
702
750
 
703
- didomiEventListener.onPreferencesClickVendorDisagree = { event, vendorId in
704
- self.dispatchEvent(withName: "on_preferences_click_vendor_disagree", body: vendorId)
751
+ didomiEventListener.onPreferencesClickVendorSaveChoices = { [weak self] event in
752
+ self?.dispatchEvent(withName: "on_preferences_click_vendor_save_choices", body: "")
705
753
  }
706
754
 
707
- didomiEventListener.onPreferencesClickVendorSaveChoices = { event in
708
- self.dispatchEvent(withName: "on_preferences_click_vendor_save_choices", body: "")
755
+ didomiEventListener.onPreferencesClickSPIPurposeAgree = { [weak self] event, purposeId in
756
+ self?.dispatchEvent(withName: "on_preferences_click_spi_purpose_agree", body: purposeId)
709
757
  }
710
758
 
711
- didomiEventListener.onPreferencesClickSPIPurposeAgree = { event, purposeId in
712
- self.dispatchEvent(withName: "on_preferences_click_spi_purpose_agree", body: purposeId)
759
+ didomiEventListener.onPreferencesClickSPIPurposeDisagree = { [weak self] event, purposeId in
760
+ self?.dispatchEvent(withName: "on_preferences_click_spi_purpose_disagree", body: purposeId)
713
761
  }
714
762
 
715
- didomiEventListener.onPreferencesClickSPIPurposeDisagree = { event, purposeId in
716
- self.dispatchEvent(withName: "on_preferences_click_spi_purpose_disagree", body: purposeId)
763
+ didomiEventListener.onPreferencesClickSPICategoryAgree = { [weak self] event, categoryId in
764
+ self?.dispatchEvent(withName: "on_preferences_click_spi_category_agree", body: categoryId)
717
765
  }
718
766
 
719
- didomiEventListener.onPreferencesClickSPICategoryAgree = { event, categoryId in
720
- self.dispatchEvent(withName: "on_preferences_click_spi_category_agree", body: categoryId)
767
+ didomiEventListener.onPreferencesClickSPICategoryDisagree = { [weak self] event, categoryId in
768
+ self?.dispatchEvent(withName: "on_preferences_click_spi_category_disagree", body: categoryId)
721
769
  }
722
770
 
723
- didomiEventListener.onPreferencesClickSPICategoryDisagree = { event, categoryId in
724
- self.dispatchEvent(withName: "on_preferences_click_spi_category_disagree", body: categoryId)
771
+ didomiEventListener.onPreferencesClickSPIPurposeSaveChoices = { [weak self] event in
772
+ self?.dispatchEvent(withName: "on_preferences_click_spi_purpose_save_choices", body: "")
725
773
  }
726
774
 
727
- didomiEventListener.onPreferencesClickSPIPurposeSaveChoices = { event in
728
- self.dispatchEvent(withName: "on_preferences_click_spi_purpose_save_choices", body: "")
775
+ didomiEventListener.onSyncDone = { [weak self] event, organizationUserId in
776
+ self?.dispatchEvent(withName: "on_sync_done", body: organizationUserId)
729
777
  }
730
778
 
731
- didomiEventListener.onSyncDone = { event, organizationUserId in
732
- self.dispatchEvent(withName: "on_sync_done", body: organizationUserId)
779
+ didomiEventListener.onSyncReady = { [weak self] event in
780
+ let callbackIndex = self?.syncAcknowledgedCallbackIndex ?? -1
781
+ self?.syncAcknowledgedCallbackIndex += 1
782
+ self?.syncAcknowledgedCallbacks[callbackIndex] = event.syncAcknowledged
783
+ let result = [
784
+ "statusApplied": event.statusApplied,
785
+ "syncAcknowledgedIndex": callbackIndex
786
+ ]
787
+ self?.dispatchEvent(withName: "on_sync_ready", body: result)
733
788
  }
734
789
 
735
- didomiEventListener.onSyncError = { event, error in
736
- self.dispatchEvent(withName: "on_sync_error", body: error)
790
+ didomiEventListener.onSyncError = { [weak self] event, error in
791
+ self?.dispatchEvent(withName: "on_sync_error", body: error)
737
792
  }
738
793
 
739
- didomiEventListener.onLanguageUpdated = { event, languageCode in
740
- self.dispatchEvent(withName: "on_language_updated", body: languageCode)
794
+ didomiEventListener.onLanguageUpdated = { [weak self] event, languageCode in
795
+ self?.dispatchEvent(withName: "on_language_updated", body: languageCode)
741
796
  }
742
797
 
743
- didomiEventListener.onLanguageUpdateFailed = { event, reason in
744
- self.dispatchEvent(withName: "on_language_update_failed", body: reason)
798
+ didomiEventListener.onLanguageUpdateFailed = { [weak self] event, reason in
799
+ self?.dispatchEvent(withName: "on_language_update_failed", body: reason)
745
800
  }
746
801
 
747
802
  Didomi.shared.addEventListener(listener: didomiEventListener)
@@ -7,5 +7,5 @@ exports.DIDOMI_VERSION = exports.DIDOMI_USER_AGENT_NAME = void 0;
7
7
  // User agent name
8
8
  const DIDOMI_USER_AGENT_NAME = exports.DIDOMI_USER_AGENT_NAME = "Didomi React-Native SDK";
9
9
  // User agent version
10
- const DIDOMI_VERSION = exports.DIDOMI_VERSION = "2.1.0";
10
+ const DIDOMI_VERSION = exports.DIDOMI_VERSION = "2.3.0";
11
11
  //# sourceMappingURL=Constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DIDOMI_USER_AGENT_NAME","exports","DIDOMI_VERSION"],"sources":["Constants.ts"],"sourcesContent":["// User agent name\nexport const DIDOMI_USER_AGENT_NAME = \"Didomi React-Native SDK\"\n// User agent version\nexport const DIDOMI_VERSION = \"2.1.0\"\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,yBAAyB;AAC/D;AACO,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,OAAO","ignoreList":[]}
1
+ {"version":3,"names":["DIDOMI_USER_AGENT_NAME","exports","DIDOMI_VERSION"],"sources":["Constants.ts"],"sourcesContent":["// User agent name\nexport const DIDOMI_USER_AGENT_NAME = \"Didomi React-Native SDK\"\n// User agent version\nexport const DIDOMI_VERSION = \"2.3.0\"\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,yBAAyB;AAC/D;AACO,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,OAAO","ignoreList":[]}