cm-sdk-react-native-v3 3.5.3 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +13 -1
  2. package/android/build.gradle +5 -5
  3. package/android/gradle.properties +3 -3
  4. package/android/src/main/java/com/cmsdkreactnativev3/CmSdkReactNativeV3Module.kt +43 -139
  5. package/android/src/main/java/com/cmsdkreactnativev3/CmSdkReactNativeV3Package.kt +24 -4
  6. package/ios/CmSdkReactNativeV3-Bridging-Header.h +4 -0
  7. package/ios/CmSdkReactNativeV3.mm +42 -76
  8. package/ios/CmSdkReactNativeV3.swift +37 -120
  9. package/lib/commonjs/NativeCmSdkReactNativeV3.js +11 -0
  10. package/lib/commonjs/NativeCmSdkReactNativeV3.js.map +1 -0
  11. package/lib/commonjs/index.js +108 -36
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/module/NativeCmSdkReactNativeV3.js +10 -0
  14. package/lib/module/NativeCmSdkReactNativeV3.js.map +1 -0
  15. package/lib/module/index.js +86 -34
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/typescript/commonjs/src/NativeCmSdkReactNativeV3.d.ts +68 -0
  18. package/lib/typescript/commonjs/src/NativeCmSdkReactNativeV3.d.ts.map +1 -0
  19. package/lib/typescript/commonjs/src/index.d.ts +25 -32
  20. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  21. package/lib/typescript/module/src/NativeCmSdkReactNativeV3.d.ts +68 -0
  22. package/lib/typescript/module/src/NativeCmSdkReactNativeV3.d.ts.map +1 -0
  23. package/lib/typescript/module/src/index.d.ts +25 -32
  24. package/lib/typescript/module/src/index.d.ts.map +1 -1
  25. package/package.json +8 -2
  26. package/react-native-cm-sdk-react-native-v3.podspec +1 -1
  27. package/src/NativeCmSdkReactNativeV3.ts +92 -0
  28. package/src/index.tsx +125 -39
package/README.md CHANGED
@@ -1,9 +1,21 @@
1
- # ``consentmanager CMP SDK v3.5.0``
1
+ # ``consentmanager CMP SDK v3.6.0``
2
2
 
3
3
  # cm-sdk-react-native-v3
4
4
 
5
5
  cm-sdk-react-native-v3 is a comprehensive Consent Management Platform (CMP) SDK bridge for React Native developed applications. It provides easy-to-use APIs for handling user consent in compliance with various privacy regulations.
6
6
 
7
+ ## ✨ New Architecture Support
8
+
9
+ **Version 3.6.0 now supports React Native's New Architecture (TurboModules + Fabric)!**
10
+
11
+ - ✅ **Full backward compatibility** with legacy architecture
12
+ - ✅ **Automatic detection** and fallback mechanism
13
+ - ✅ **Zero breaking changes** to existing APIs
14
+ - ✅ **Enhanced performance** with TurboModules
15
+ - ✅ **Type safety** with automatic code generation
16
+
17
+ See [NEW_ARCHITECTURE.md](./NEW_ARCHITECTURE.md) for detailed information.
18
+
7
19
  For further information, please refer to [our documentation](https://help.consentmanager.net/books/cmp/chapter/integration-into-your-app---v3)
8
20
  ## License
9
21
 
@@ -8,7 +8,7 @@ buildscript {
8
8
  }
9
9
 
10
10
  dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.1"
11
+ classpath "com.android.tools.build:gradle:8.11.1"
12
12
  // noinspection DifferentKotlinGradleVersion
13
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
14
  }
@@ -58,11 +58,11 @@ android {
58
58
  }
59
59
  }
60
60
 
61
- compileSdkVersion 34
61
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
62
62
 
63
63
  defaultConfig {
64
- minSdkVersion 23
65
- targetSdkVersion 34
64
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
65
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
66
66
 
67
67
  }
68
68
 
@@ -96,5 +96,5 @@ dependencies {
96
96
  //noinspection GradleDynamicVersion
97
97
  implementation "com.facebook.react:react-native:+"
98
98
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
99
- implementation "net.consentmanager.sdkv3:cmsdkv3:3.5.1"
99
+ implementation "net.consentmanager.sdkv3:cmsdkv3:3.6.0"
100
100
  }
@@ -1,5 +1,5 @@
1
- CmSdkReactNativeV3_kotlinVersion=1.7.0
1
+ CmSdkReactNativeV3_kotlinVersion=1.9.22
2
2
  CmSdkReactNativeV3_minSdkVersion=25
3
- CmSdkReactNativeV3_targetSdkVersion=31
4
- CmSdkReactNativeV3_compileSdkVersion=31
3
+ CmSdkReactNativeV3_targetSdkVersion=36
4
+ CmSdkReactNativeV3_compileSdkVersion=36
5
5
  CmSdkReactNativeV3_ndkversion=21.4.7075529
@@ -3,18 +3,17 @@ package com.cmsdkreactnativev3
3
3
  import android.os.Handler
4
4
  import android.os.Looper
5
5
  import android.util.Log
6
+ import com.facebook.fbreact.specs.NativeCmSdkReactNativeV3Spec
6
7
  import com.facebook.react.bridge.Arguments
7
8
  import com.facebook.react.bridge.LifecycleEventListener
8
9
  import com.facebook.react.bridge.Promise
9
10
  import com.facebook.react.bridge.ReactApplicationContext
10
- import com.facebook.react.bridge.ReactContextBaseJavaModule
11
11
  import com.facebook.react.bridge.ReactMethod
12
12
  import com.facebook.react.bridge.ReadableArray
13
13
  import com.facebook.react.bridge.ReadableMap
14
14
  import com.facebook.react.bridge.ReadableType
15
15
  import com.facebook.react.bridge.WritableArray
16
16
  import com.facebook.react.bridge.WritableMap
17
- import com.facebook.react.modules.core.DeviceEventManagerModule
18
17
  import kotlinx.coroutines.CoroutineScope
19
18
  import kotlinx.coroutines.Dispatchers
20
19
  import kotlinx.coroutines.launch
@@ -26,7 +25,7 @@ import net.consentmanager.cm_sdk_android_v3.UrlConfig
26
25
  import net.consentmanager.cm_sdk_android_v3.UserConsentStatus
27
26
 
28
27
  class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
29
- ReactContextBaseJavaModule(reactContext), LifecycleEventListener, CMPManagerDelegate {
28
+ NativeCmSdkReactNativeV3Spec(reactContext), LifecycleEventListener, CMPManagerDelegate {
30
29
 
31
30
  private lateinit var cmpManager: CMPManager
32
31
  private val scope = CoroutineScope(Dispatchers.Main)
@@ -34,6 +33,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
34
33
  private var webViewConfig: ConsentLayerUIConfig
35
34
  private val uiThreadHandler = Handler(Looper.getMainLooper())
36
35
  private var isInitialized = false
36
+ private var storedATTStatus: Int = 0
37
37
 
38
38
 
39
39
  init {
@@ -50,18 +50,25 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
50
50
  }
51
51
 
52
52
  override fun getName(): String = NAME
53
+
54
+ override fun invalidate() {
55
+ super.invalidate()
56
+ if (::cmpManager.isInitialized) {
57
+ cmpManager.onActivityDestroyed()
58
+ }
59
+ }
53
60
 
54
61
  private fun runOnUiThread(runnable: Runnable) {
55
62
  uiThreadHandler.post(runnable)
56
63
  }
57
64
 
58
65
  @ReactMethod
59
- fun addListener(eventName: String?) {
66
+ override fun addListener(eventName: String?) {
60
67
  // Required for NativeEventEmitter - React Native calls this automatically
61
68
  }
62
69
 
63
70
  @ReactMethod
64
- fun removeListeners(count: Int) {
71
+ override fun removeListeners(count: Double) {
65
72
  // Required for NativeEventEmitter - React Native calls this automatically
66
73
  }
67
74
 
@@ -70,7 +77,17 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
70
77
 
71
78
 
72
79
  @ReactMethod
73
- fun setWebViewConfig(config: ReadableMap, promise: Promise) {
80
+ override fun setATTStatus(status: Double, promise: Promise) {
81
+ try {
82
+ this.storedATTStatus = status.toInt()
83
+ promise.resolve(null)
84
+ } catch (e: Exception) {
85
+ promise.reject("ERROR", "Failed to set ATT status: ${e.message}")
86
+ }
87
+ }
88
+
89
+ @ReactMethod
90
+ override fun setWebViewConfig(config: ReadableMap, promise: Promise) {
74
91
  runOnUiThread {
75
92
  try {
76
93
  val position = when (config.getString("position")) {
@@ -97,15 +114,16 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
97
114
  }
98
115
 
99
116
  @ReactMethod
100
- fun setUrlConfig(config: ReadableMap, promise: Promise) {
117
+ override fun setUrlConfig(config: ReadableMap, promise: Promise) {
101
118
  runOnUiThread {
102
119
  try {
103
120
  val id = config.getString("id") ?: throw IllegalArgumentException("Missing 'id'")
104
121
  val domain = config.getString("domain") ?: throw IllegalArgumentException("Missing 'domain'")
105
122
  val language = config.getString("language") ?: throw IllegalArgumentException("Missing 'language'")
106
123
  val appName = config.getString("appName") ?: throw IllegalArgumentException("Missing 'appName'")
124
+ val noHash = if (config.hasKey("noHash")) config.getBoolean("noHash") else false
107
125
 
108
- this.urlConfig = UrlConfig(id, domain, language, appName)
126
+ this.urlConfig = UrlConfig(id, domain, language, appName, noHash = noHash)
109
127
 
110
128
  initializeCMPManager()
111
129
 
@@ -155,7 +173,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
155
173
  * Gets the comprehensive user consent status
156
174
  */
157
175
  @ReactMethod
158
- fun getUserStatus(promise: Promise) {
176
+ override fun getUserStatus(promise: Promise) {
159
177
  try {
160
178
  val userStatus = cmpManager.getUserStatus()
161
179
  val result = Arguments.createMap().apply {
@@ -187,7 +205,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
187
205
  * Gets the consent status for a specific purpose
188
206
  */
189
207
  @ReactMethod
190
- fun getStatusForPurpose(purposeId: String, promise: Promise) {
208
+ override fun getStatusForPurpose(purposeId: String, promise: Promise) {
191
209
  try {
192
210
  val status = cmpManager.getStatusForPurpose(purposeId)
193
211
  promise.resolve(status.toString())
@@ -200,7 +218,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
200
218
  * Gets the consent status for a specific vendor
201
219
  */
202
220
  @ReactMethod
203
- fun getStatusForVendor(vendorId: String, promise: Promise) {
221
+ override fun getStatusForVendor(vendorId: String, promise: Promise) {
204
222
  try {
205
223
  val status = cmpManager.getStatusForVendor(vendorId)
206
224
  promise.resolve(status.toString())
@@ -213,7 +231,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
213
231
  * Gets Google Consent Mode v2 compatible settings
214
232
  */
215
233
  @ReactMethod
216
- fun getGoogleConsentModeStatus(promise: Promise) {
234
+ override fun getGoogleConsentModeStatus(promise: Promise) {
217
235
  try {
218
236
  val consentModeStatus = cmpManager.getGoogleConsentModeStatus()
219
237
  val result = Arguments.createMap()
@@ -232,7 +250,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
232
250
  * Replacement for openConsentLayer - force opens the consent UI
233
251
  */
234
252
  @ReactMethod
235
- fun forceOpen(jumpToSettings: Boolean, promise: Promise) {
253
+ override fun forceOpen(jumpToSettings: Boolean, promise: Promise) {
236
254
  scope.launch {
237
255
  try {
238
256
  currentActivity?.let { cmpManager.setActivity(it) }
@@ -254,7 +272,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
254
272
  * Replacement for checkWithServerAndOpenIfNecessary - checks with server and opens if needed
255
273
  */
256
274
  @ReactMethod
257
- fun checkAndOpen(jumpToSettings: Boolean, promise: Promise) {
275
+ override fun checkAndOpen(jumpToSettings: Boolean, promise: Promise) {
258
276
  scope.launch {
259
277
  try {
260
278
  currentActivity?.let { cmpManager.setActivity(it) }
@@ -276,7 +294,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
276
294
  * Import a CMP information string
277
295
  */
278
296
  @ReactMethod
279
- fun importCMPInfo(cmpString: String, promise: Promise) {
297
+ override fun importCMPInfo(cmpString: String, promise: Promise) {
280
298
  scope.launch {
281
299
  try {
282
300
  cmpManager.importCMPInfo(cmpString) { result ->
@@ -296,7 +314,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
296
314
  * Reset all consent management data
297
315
  */
298
316
  @ReactMethod
299
- fun resetConsentManagementData(promise: Promise) {
317
+ override fun resetConsentManagementData(promise: Promise) {
300
318
  try {
301
319
  cmpManager.resetConsentManagementData()
302
320
  promise.resolve(true)
@@ -306,125 +324,12 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
306
324
  }
307
325
 
308
326
  @ReactMethod
309
- fun checkWithServerAndOpenIfNecessary(promise: Promise) {
310
- scope.launch {
311
- try {
312
- currentActivity?.let { cmpManager.setActivity(it) }
313
-
314
- cmpManager.checkAndOpen(false) { result ->
315
- if (result.isSuccess) {
316
- promise.resolve(true)
317
- } else {
318
- promise.reject("ERROR", result.exceptionOrNull()?.message ?: "Unknown error")
319
- }
320
- }
321
- } catch (e: Exception) {
322
- promise.reject("ERROR", "Failed to check with server: ${e.message}", e)
323
- }
324
- }
325
- }
326
-
327
- @ReactMethod
328
- fun openConsentLayer(promise: Promise) {
329
- scope.launch {
330
- try {
331
- currentActivity?.let { cmpManager.setActivity(it) }
332
- cmpManager.forceOpen(false) { result ->
333
- if (result.isSuccess) {
334
- promise.resolve(true)
335
- } else {
336
- promise.reject("ERROR", result.exceptionOrNull()?.message ?: "Unknown error")
337
- }
338
- }
339
- } catch (e: Exception) {
340
- promise.reject("ERROR", "Failed to open consent layer: ${e.message}", e)
341
- }
342
- }
343
- }
344
-
345
- @ReactMethod
346
- fun jumpToSettings(promise: Promise) {
347
- scope.launch {
348
- try {
349
- currentActivity?.let { cmpManager.setActivity(it) }
350
- cmpManager.forceOpen(true) { result ->
351
- if (result.isSuccess) {
352
- promise.resolve(true)
353
- } else {
354
- promise.reject("ERROR", result.exceptionOrNull()?.message ?: "Unknown error")
355
- }
356
- }
357
- } catch (e: Exception) {
358
- promise.reject("ERROR", "Failed to jump to settings: ${e.message}", e)
359
- }
360
- }
361
- }
362
-
363
- @ReactMethod
364
- fun checkIfConsentIsRequired(promise: Promise) {
365
- scope.launch {
366
- try {
367
- cmpManager.checkIfConsentIsRequired { isRequired ->
368
- promise.resolve(isRequired)
369
- }
370
- } catch (e: Exception) {
371
- promise.reject("ERROR", "Failed to check if consent is required: ${e.message}", e)
372
- }
373
- }
374
- }
375
-
376
- @ReactMethod
377
- fun hasUserChoice(promise: Promise) {
378
- promise.resolve(cmpManager.hasUserChoice())
379
- }
380
-
381
- @ReactMethod
382
- fun hasPurposeConsent(purposeId: String, promise: Promise) {
383
- promise.resolve(cmpManager.hasPurposeConsent(purposeId))
384
- }
385
-
386
- @ReactMethod
387
- fun hasVendorConsent(vendorId: String, promise: Promise) {
388
- promise.resolve(cmpManager.hasVendorConsent(vendorId))
389
- }
390
-
391
- @ReactMethod
392
- fun exportCMPInfo(promise: Promise) {
327
+ override fun exportCMPInfo(promise: Promise) {
393
328
  promise.resolve(cmpManager.exportCMPInfo())
394
329
  }
395
330
 
396
331
  @ReactMethod
397
- fun getAllPurposesIDs(promise: Promise) {
398
- promise.resolve(cmpManager.getAllPurposesIDs().toWritableArray())
399
- }
400
-
401
- @ReactMethod
402
- fun getEnabledPurposesIDs(promise: Promise) {
403
- promise.resolve(cmpManager.getEnabledPurposesIDs().toWritableArray())
404
- }
405
-
406
- @ReactMethod
407
- fun getDisabledPurposesIDs(promise: Promise) {
408
- promise.resolve(cmpManager.getDisabledPurposesIDs().toWritableArray())
409
- }
410
-
411
- @ReactMethod
412
- fun getAllVendorsIDs(promise: Promise) {
413
- promise.resolve(cmpManager.getAllVendorsIDs().toWritableArray())
414
- }
415
-
416
- @ReactMethod
417
- fun getEnabledVendorsIDs(promise: Promise) {
418
- promise.resolve(cmpManager.getEnabledVendorsIDs().toWritableArray())
419
- }
420
-
421
- @ReactMethod
422
- fun getDisabledVendorsIDs(promise: Promise) {
423
- promise.resolve(cmpManager.getDisabledVendorsIDs().toWritableArray())
424
- }
425
-
426
- @ReactMethod
427
- fun acceptVendors(vendors: ReadableArray, promise: Promise) {
332
+ override fun acceptVendors(vendors: ReadableArray, promise: Promise) {
428
333
  scope.launch {
429
334
  try {
430
335
  Log.d("CmSdkReactNativeV3", "Accepting vendors: $vendors")
@@ -443,7 +348,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
443
348
  }
444
349
 
445
350
  @ReactMethod
446
- fun rejectVendors(vendors: ReadableArray, promise: Promise) {
351
+ override fun rejectVendors(vendors: ReadableArray, promise: Promise) {
447
352
  scope.launch {
448
353
  try {
449
354
  Log.d("CmSdkReactNativeV3", "Rejecting vendors: $vendors")
@@ -461,7 +366,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
461
366
  }
462
367
 
463
368
  @ReactMethod
464
- fun acceptPurposes(purposes: ReadableArray, updatePurpose: Boolean, promise: Promise) {
369
+ override fun acceptPurposes(purposes: ReadableArray, updatePurpose: Boolean, promise: Promise) {
465
370
  scope.launch {
466
371
  try {
467
372
  Log.d("Cmsdkreactnativev3", "Rejecting purposes: $purposes")
@@ -480,7 +385,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
480
385
  }
481
386
 
482
387
  @ReactMethod
483
- fun rejectPurposes(purposes: ReadableArray, updateVendor: Boolean, promise: Promise) {
388
+ override fun rejectPurposes(purposes: ReadableArray, updateVendor: Boolean, promise: Promise) {
484
389
  scope.launch {
485
390
  try {
486
391
  Log.d("Cmsdkreactnativev3", "Rejecting purposes: $purposes")
@@ -498,7 +403,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
498
403
  }
499
404
 
500
405
  @ReactMethod
501
- fun rejectAll(promise: Promise) {
406
+ override fun rejectAll(promise: Promise) {
502
407
  scope.launch {
503
408
  try {
504
409
  cmpManager.rejectAll { result ->
@@ -515,7 +420,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
515
420
  }
516
421
 
517
422
  @ReactMethod
518
- fun acceptAll(promise: Promise) {
423
+ override fun acceptAll(promise: Promise) {
519
424
  scope.launch {
520
425
  try {
521
426
  cmpManager.acceptAll { result ->
@@ -564,9 +469,8 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
564
469
 
565
470
  private fun sendEvent(eventName: String, params: WritableMap?) {
566
471
  Log.d("CmSdkReactNativeV3", "sendEvent called: $eventName")
567
- reactApplicationContext
568
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
569
- .emit(eventName, params)
472
+ // Bridgeless-compatible: emitDeviceEvent works in all modes (legacy, new arch, bridgeless)
473
+ reactApplicationContext.emitDeviceEvent(eventName, params)
570
474
  }
571
475
 
572
476
  private fun List<String>.toWritableArray(): WritableArray {
@@ -1,14 +1,34 @@
1
1
  package com.cmsdkreactnativev3
2
2
 
3
- import com.facebook.react.ReactPackage
3
+ import com.facebook.react.TurboReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
6
8
  import com.facebook.react.uimanager.ViewManager
7
9
 
10
+ class CmSdkReactNativeV3Package : TurboReactPackage() {
11
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
+ return if (name == CmSdkReactNativeV3Module.NAME) {
13
+ CmSdkReactNativeV3Module(reactContext)
14
+ } else {
15
+ null
16
+ }
17
+ }
8
18
 
9
- class CmSdkReactNativeV3Package : ReactPackage {
10
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
- return listOf(CmSdkReactNativeV3Module(reactContext))
19
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
+ return ReactModuleInfoProvider {
21
+ mapOf(
22
+ CmSdkReactNativeV3Module.NAME to ReactModuleInfo(
23
+ CmSdkReactNativeV3Module.NAME,
24
+ CmSdkReactNativeV3Module.NAME,
25
+ false,
26
+ false,
27
+ false,
28
+ true
29
+ )
30
+ )
31
+ }
12
32
  }
13
33
 
14
34
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
@@ -1,3 +1,7 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import <React/RCTViewManager.h>
3
3
  #import <React/RCTEventEmitter.h>
4
+
5
+ #ifdef RCT_NEW_ARCH_ENABLED
6
+ #import <CmSdkReactNativeV3Spec/CmSdkReactNativeV3Spec.h>
7
+ #endif
@@ -1,121 +1,87 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import <React/RCTEventEmitter.h>
3
3
 
4
- @interface RCT_EXTERN_MODULE(CmSdkReactNativeV3, RCTEventEmitter)
4
+ #ifdef RCT_NEW_ARCH_ENABLED
5
+ #import <CmSdkReactNativeV3Spec/CmSdkReactNativeV3Spec.h>
6
+ #endif
5
7
 
6
- // Event emitter methods
7
- RCT_EXTERN_METHOD(supportedEvents)
8
+ // Use RCT_EXTERN_MODULE for both architectures when using Swift
9
+ @interface RCT_EXTERN_MODULE(CmSdkReactNativeV3, RCTEventEmitter)
8
10
 
9
11
  // Core methods
10
12
  RCT_EXTERN_METHOD(setUrlConfig:(NSDictionary *)config
11
- withResolver:(RCTPromiseResolveBlock)resolve
12
- withRejecter:(RCTPromiseRejectBlock)reject)
13
+ resolve:(RCTPromiseResolveBlock)resolve
14
+ reject:(RCTPromiseRejectBlock)reject)
13
15
 
14
16
  RCT_EXTERN_METHOD(setWebViewConfig:(NSDictionary *)config
15
- withResolver:(RCTPromiseResolveBlock)resolve
16
- withRejecter:(RCTPromiseRejectBlock)reject)
17
+ resolve:(RCTPromiseResolveBlock)resolve
18
+ reject:(RCTPromiseRejectBlock)reject)
19
+
20
+ RCT_EXTERN_METHOD(setATTStatus:(NSInteger)status
21
+ resolve:(RCTPromiseResolveBlock)resolve
22
+ reject:(RCTPromiseRejectBlock)reject)
17
23
 
18
- // New methods
24
+ // Main methods
19
25
  RCT_EXTERN_METHOD(checkAndOpen:(BOOL)jumpToSettings
20
- withResolver:(RCTPromiseResolveBlock)resolve
21
- withRejecter:(RCTPromiseRejectBlock)reject)
26
+ resolve:(RCTPromiseResolveBlock)resolve
27
+ reject:(RCTPromiseRejectBlock)reject)
22
28
 
23
29
  RCT_EXTERN_METHOD(forceOpen:(BOOL)jumpToSettings
24
- withResolver:(RCTPromiseResolveBlock)resolve
25
- withRejecter:(RCTPromiseRejectBlock)reject)
30
+ resolve:(RCTPromiseResolveBlock)resolve
31
+ reject:(RCTPromiseRejectBlock)reject)
26
32
 
27
33
  RCT_EXTERN_METHOD(getUserStatus:(RCTPromiseResolveBlock)resolve
28
- withRejecter:(RCTPromiseRejectBlock)reject)
34
+ reject:(RCTPromiseRejectBlock)reject)
29
35
 
30
36
  RCT_EXTERN_METHOD(getStatusForPurpose:(NSString *)purposeId
31
- withResolver:(RCTPromiseResolveBlock)resolve
32
- withRejecter:(RCTPromiseRejectBlock)reject)
37
+ resolve:(RCTPromiseResolveBlock)resolve
38
+ reject:(RCTPromiseRejectBlock)reject)
33
39
 
34
40
  RCT_EXTERN_METHOD(getStatusForVendor:(NSString *)vendorId
35
- withResolver:(RCTPromiseResolveBlock)resolve
36
- withRejecter:(RCTPromiseRejectBlock)reject)
41
+ resolve:(RCTPromiseResolveBlock)resolve
42
+ reject:(RCTPromiseRejectBlock)reject)
37
43
 
38
44
  RCT_EXTERN_METHOD(getGoogleConsentModeStatus:(RCTPromiseResolveBlock)resolve
39
- withRejecter:(RCTPromiseRejectBlock)reject)
40
-
41
- // Legacy methods
42
- RCT_EXTERN_METHOD(checkWithServerAndOpenIfNecessary:(RCTPromiseResolveBlock)resolve
43
- withRejecter:(RCTPromiseRejectBlock)reject)
44
-
45
- RCT_EXTERN_METHOD(openConsentLayer:(RCTPromiseResolveBlock)resolve
46
- withRejecter:(RCTPromiseRejectBlock)reject)
47
-
48
- RCT_EXTERN_METHOD(jumpToSettings:(RCTPromiseResolveBlock)resolve
49
- withRejecter:(RCTPromiseRejectBlock)reject)
50
-
51
- RCT_EXTERN_METHOD(checkIfConsentIsRequired:(RCTPromiseResolveBlock)resolve
52
- withRejecter:(RCTPromiseRejectBlock)reject)
53
-
54
- // Consent status methods
55
- RCT_EXTERN_METHOD(hasUserChoice:(RCTPromiseResolveBlock)resolve
56
- withRejecter:(RCTPromiseRejectBlock)reject)
57
-
58
- RCT_EXTERN_METHOD(hasPurposeConsent:(NSString *)purposeId
59
- withResolver:(RCTPromiseResolveBlock)resolve
60
- withRejecter:(RCTPromiseRejectBlock)reject)
61
-
62
- RCT_EXTERN_METHOD(hasVendorConsent:(NSString *)vendorId
63
- withResolver:(RCTPromiseResolveBlock)resolve
64
- withRejecter:(RCTPromiseRejectBlock)reject)
45
+ reject:(RCTPromiseRejectBlock)reject)
65
46
 
66
47
  RCT_EXTERN_METHOD(exportCMPInfo:(RCTPromiseResolveBlock)resolve
67
- withRejecter:(RCTPromiseRejectBlock)reject)
68
-
69
- // Purpose and vendor methods
70
- RCT_EXTERN_METHOD(getAllPurposesIDs:(RCTPromiseResolveBlock)resolve
71
- withRejecter:(RCTPromiseRejectBlock)reject)
72
-
73
- RCT_EXTERN_METHOD(getEnabledPurposesIDs:(RCTPromiseResolveBlock)resolve
74
- withRejecter:(RCTPromiseRejectBlock)reject)
75
-
76
- RCT_EXTERN_METHOD(getDisabledPurposesIDs:(RCTPromiseResolveBlock)resolve
77
- withRejecter:(RCTPromiseRejectBlock)reject)
78
-
79
- RCT_EXTERN_METHOD(getAllVendorsIDs:(RCTPromiseResolveBlock)resolve
80
- withRejecter:(RCTPromiseRejectBlock)reject)
81
-
82
- RCT_EXTERN_METHOD(getEnabledVendorsIDs:(RCTPromiseResolveBlock)resolve
83
- withRejecter:(RCTPromiseRejectBlock)reject)
84
-
85
- RCT_EXTERN_METHOD(getDisabledVendorsIDs:(RCTPromiseResolveBlock)resolve
86
- withRejecter:(RCTPromiseRejectBlock)reject)
48
+ reject:(RCTPromiseRejectBlock)reject)
87
49
 
88
50
  // Consent modification methods
89
51
  RCT_EXTERN_METHOD(acceptVendors:(NSArray *)vendors
90
- withResolver:(RCTPromiseResolveBlock)resolve
91
- withRejecter:(RCTPromiseRejectBlock)reject)
52
+ resolve:(RCTPromiseResolveBlock)resolve
53
+ reject:(RCTPromiseRejectBlock)reject)
92
54
 
93
55
  RCT_EXTERN_METHOD(rejectVendors:(NSArray *)vendors
94
- withResolver:(RCTPromiseResolveBlock)resolve
95
- withRejecter:(RCTPromiseRejectBlock)reject)
56
+ resolve:(RCTPromiseResolveBlock)resolve
57
+ reject:(RCTPromiseRejectBlock)reject)
96
58
 
97
59
  RCT_EXTERN_METHOD(acceptPurposes:(NSArray *)purposes
98
60
  updatePurpose:(BOOL)updatePurpose
99
- withResolver:(RCTPromiseResolveBlock)resolve
100
- withRejecter:(RCTPromiseRejectBlock)reject)
61
+ resolve:(RCTPromiseResolveBlock)resolve
62
+ reject:(RCTPromiseRejectBlock)reject)
101
63
 
102
64
  RCT_EXTERN_METHOD(rejectPurposes:(NSArray *)purposes
103
65
  updateVendor:(BOOL)updateVendor
104
- withResolver:(RCTPromiseResolveBlock)resolve
105
- withRejecter:(RCTPromiseRejectBlock)reject)
66
+ resolve:(RCTPromiseResolveBlock)resolve
67
+ reject:(RCTPromiseRejectBlock)reject)
106
68
 
107
69
  RCT_EXTERN_METHOD(rejectAll:(RCTPromiseResolveBlock)resolve
108
- withRejecter:(RCTPromiseRejectBlock)reject)
70
+ reject:(RCTPromiseRejectBlock)reject)
109
71
 
110
72
  RCT_EXTERN_METHOD(acceptAll:(RCTPromiseResolveBlock)resolve
111
- withRejecter:(RCTPromiseRejectBlock)reject)
73
+ reject:(RCTPromiseRejectBlock)reject)
112
74
 
113
75
  RCT_EXTERN_METHOD(importCMPInfo:(NSString *)cmpString
114
- withResolver:(RCTPromiseResolveBlock)resolve
115
- withRejecter:(RCTPromiseRejectBlock)reject)
76
+ resolve:(RCTPromiseResolveBlock)resolve
77
+ reject:(RCTPromiseRejectBlock)reject)
116
78
 
117
79
  RCT_EXTERN_METHOD(resetConsentManagementData:(RCTPromiseResolveBlock)resolve
118
- withRejecter:(RCTPromiseRejectBlock)reject)
80
+ reject:(RCTPromiseRejectBlock)reject)
81
+
82
+ // Event emitter support methods
83
+ RCT_EXTERN_METHOD(addListener:(NSString *)eventName)
84
+ RCT_EXTERN_METHOD(removeListeners:(double)count)
119
85
 
120
86
  + (BOOL)requiresMainQueueSetup
121
87
  {