cm-sdk-react-native-v3 3.6.0 → 3.6.2
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/README.md +2 -13
- package/android/build.gradle +1 -14
- package/android/src/main/java/com/cmsdkreactnativev3/CmSdkReactNativeV3Module.kt +78 -52
- package/android/src/main/java/com/cmsdkreactnativev3/CmSdkReactNativeV3Package.kt +6 -29
- package/ios/CmSdkReactNativeV3.mm +33 -32
- package/ios/CmSdkReactNativeV3.swift +162 -50
- package/lib/commonjs/NativeCmSdkReactNativeV3.js +32 -2
- package/lib/commonjs/NativeCmSdkReactNativeV3.js.map +1 -1
- package/lib/commonjs/index.js +138 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeCmSdkReactNativeV3.js +32 -2
- package/lib/module/NativeCmSdkReactNativeV3.js.map +1 -1
- package/lib/module/index.js +114 -7
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeCmSdkReactNativeV3.d.ts +48 -10
- package/lib/typescript/commonjs/src/NativeCmSdkReactNativeV3.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +14 -4
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeCmSdkReactNativeV3.d.ts +48 -10
- package/lib/typescript/module/src/NativeCmSdkReactNativeV3.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +14 -4
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +4 -7
- package/react-native-cm-sdk-react-native-v3.podspec +1 -24
- package/src/NativeCmSdkReactNativeV3.ts +51 -13
- package/src/index.tsx +148 -14
package/README.md
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
# ``consentmanager CMP SDK v3.6.
|
|
1
|
+
# ``consentmanager CMP SDK v3.6.2``
|
|
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
|
-
|
|
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.
|
|
6
|
+
This package targets the legacy React Native bridge (old architecture) only.
|
|
18
7
|
|
|
19
8
|
For further information, please refer to [our documentation](https://help.consentmanager.net/books/cmp/chapter/integration-into-your-app---v3)
|
|
20
9
|
## License
|
package/android/build.gradle
CHANGED
|
@@ -14,22 +14,9 @@ buildscript {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
def reactNativeArchitectures() {
|
|
18
|
-
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
19
|
-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
def isNewArchitectureEnabled() {
|
|
23
|
-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
17
|
apply plugin: "com.android.library"
|
|
27
18
|
apply plugin: "kotlin-android"
|
|
28
19
|
|
|
29
|
-
if (isNewArchitectureEnabled()) {
|
|
30
|
-
apply plugin: "com.facebook.react"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
20
|
def getExtOrDefault(name) {
|
|
34
21
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["CmSdkReactNativeV3_" + name]
|
|
35
22
|
}
|
|
@@ -96,5 +83,5 @@ dependencies {
|
|
|
96
83
|
//noinspection GradleDynamicVersion
|
|
97
84
|
implementation "com.facebook.react:react-native:+"
|
|
98
85
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
99
|
-
implementation "net.consentmanager.sdkv3:cmsdkv3:3.
|
|
86
|
+
implementation "net.consentmanager.sdkv3:cmsdkv3:3.7.0"
|
|
100
87
|
}
|
|
@@ -3,7 +3,7 @@ package com.cmsdkreactnativev3
|
|
|
3
3
|
import android.os.Handler
|
|
4
4
|
import android.os.Looper
|
|
5
5
|
import android.util.Log
|
|
6
|
-
import
|
|
6
|
+
import android.app.Activity
|
|
7
7
|
import com.facebook.react.bridge.Arguments
|
|
8
8
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
9
9
|
import com.facebook.react.bridge.Promise
|
|
@@ -14,6 +14,8 @@ 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.bridge.ReactContextBaseJavaModule
|
|
18
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
17
19
|
import kotlinx.coroutines.CoroutineScope
|
|
18
20
|
import kotlinx.coroutines.Dispatchers
|
|
19
21
|
import kotlinx.coroutines.launch
|
|
@@ -25,7 +27,7 @@ import net.consentmanager.cm_sdk_android_v3.UrlConfig
|
|
|
25
27
|
import net.consentmanager.cm_sdk_android_v3.UserConsentStatus
|
|
26
28
|
|
|
27
29
|
class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
28
|
-
|
|
30
|
+
ReactContextBaseJavaModule(reactContext), LifecycleEventListener, CMPManagerDelegate {
|
|
29
31
|
|
|
30
32
|
private lateinit var cmpManager: CMPManager
|
|
31
33
|
private val scope = CoroutineScope(Dispatchers.Main)
|
|
@@ -34,6 +36,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
34
36
|
private val uiThreadHandler = Handler(Looper.getMainLooper())
|
|
35
37
|
private var isInitialized = false
|
|
36
38
|
private var storedATTStatus: Int = 0
|
|
39
|
+
private var isWebViewConfigSet = false
|
|
37
40
|
|
|
38
41
|
|
|
39
42
|
init {
|
|
@@ -42,7 +45,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
42
45
|
webViewConfig = ConsentLayerUIConfig(
|
|
43
46
|
position = ConsentLayerUIConfig.Position.FULL_SCREEN,
|
|
44
47
|
backgroundStyle = ConsentLayerUIConfig.BackgroundStyle.dimmed(android.graphics.Color.BLACK, 0.5f),
|
|
45
|
-
cornerRadius =
|
|
48
|
+
cornerRadius = dpToPx(5f),
|
|
46
49
|
respectsSafeArea = true,
|
|
47
50
|
isCancelable = false,
|
|
48
51
|
allowsOrientationChanges = true
|
|
@@ -62,13 +65,16 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
62
65
|
uiThreadHandler.post(runnable)
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
private val currentActivitySafe: Activity?
|
|
69
|
+
get() = reactApplicationContext.currentActivity
|
|
70
|
+
|
|
65
71
|
@ReactMethod
|
|
66
|
-
|
|
72
|
+
fun addListener(eventName: String?) {
|
|
67
73
|
// Required for NativeEventEmitter - React Native calls this automatically
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
@ReactMethod
|
|
71
|
-
|
|
77
|
+
fun removeListeners(count: Double) {
|
|
72
78
|
// Required for NativeEventEmitter - React Native calls this automatically
|
|
73
79
|
}
|
|
74
80
|
|
|
@@ -77,7 +83,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
77
83
|
|
|
78
84
|
|
|
79
85
|
@ReactMethod
|
|
80
|
-
|
|
86
|
+
fun setATTStatus(status: Double, promise: Promise) {
|
|
81
87
|
try {
|
|
82
88
|
this.storedATTStatus = status.toInt()
|
|
83
89
|
promise.resolve(null)
|
|
@@ -87,34 +93,42 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
@ReactMethod
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"fullScreen" -> ConsentLayerUIConfig.Position.FULL_SCREEN
|
|
95
|
-
"halfScreenBottom" -> ConsentLayerUIConfig.Position.HALF_SCREEN_BOTTOM
|
|
96
|
-
"halfScreenTop" -> ConsentLayerUIConfig.Position.HALF_SCREEN_TOP
|
|
97
|
-
else -> ConsentLayerUIConfig.Position.FULL_SCREEN
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this.webViewConfig = ConsentLayerUIConfig(
|
|
101
|
-
position = position,
|
|
102
|
-
backgroundStyle = ConsentLayerUIConfig.BackgroundStyle.dimmed(android.graphics.Color.BLACK, 0.5f),
|
|
103
|
-
cornerRadius = (config.getDouble("cornerRadius") ?: 0.0).toFloat(),
|
|
104
|
-
respectsSafeArea = config.getBoolean("respectsSafeArea"),
|
|
105
|
-
isCancelable = false,
|
|
106
|
-
allowsOrientationChanges = config.getBoolean("allowsOrientationChanges")
|
|
107
|
-
)
|
|
108
|
-
|
|
96
|
+
fun setWebViewConfig(config: ReadableMap, promise: Promise) {
|
|
97
|
+
try {
|
|
98
|
+
if (::cmpManager.isInitialized && isInitialized) {
|
|
99
|
+
Log.w("CmSdkReactNativeV3", "setWebViewConfig called after CMPManager initialization. Config changes will not be applied. Set config before setUrlConfig.")
|
|
109
100
|
promise.resolve(null)
|
|
110
|
-
|
|
111
|
-
promise.reject("ERROR", "Failed to set WebView config: ${e.message}")
|
|
101
|
+
return
|
|
112
102
|
}
|
|
103
|
+
|
|
104
|
+
val position = when (config.getString("position")) {
|
|
105
|
+
"fullScreen" -> ConsentLayerUIConfig.Position.FULL_SCREEN
|
|
106
|
+
"halfScreenBottom" -> ConsentLayerUIConfig.Position.HALF_SCREEN_BOTTOM
|
|
107
|
+
"halfScreenTop" -> ConsentLayerUIConfig.Position.HALF_SCREEN_TOP
|
|
108
|
+
else -> ConsentLayerUIConfig.Position.FULL_SCREEN
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
val cornerRadiusDp = if (config.hasKey("cornerRadius")) config.getDouble("cornerRadius").toFloat() else 0f
|
|
112
|
+
val cornerRadius = dpToPx(cornerRadiusDp)
|
|
113
|
+
|
|
114
|
+
this.webViewConfig = ConsentLayerUIConfig(
|
|
115
|
+
position = position,
|
|
116
|
+
backgroundStyle = ConsentLayerUIConfig.BackgroundStyle.dimmed(android.graphics.Color.BLACK, 0.5f),
|
|
117
|
+
cornerRadius = cornerRadius,
|
|
118
|
+
respectsSafeArea = if (config.hasKey("respectsSafeArea")) config.getBoolean("respectsSafeArea") else true,
|
|
119
|
+
isCancelable = false,
|
|
120
|
+
allowsOrientationChanges = if (config.hasKey("allowsOrientationChanges")) config.getBoolean("allowsOrientationChanges") else true
|
|
121
|
+
)
|
|
122
|
+
isWebViewConfigSet = true
|
|
123
|
+
|
|
124
|
+
promise.resolve(null)
|
|
125
|
+
} catch (e: Exception) {
|
|
126
|
+
promise.reject("ERROR", "Failed to set WebView config: ${e.message}")
|
|
113
127
|
}
|
|
114
128
|
}
|
|
115
129
|
|
|
116
130
|
@ReactMethod
|
|
117
|
-
|
|
131
|
+
fun setUrlConfig(config: ReadableMap, promise: Promise) {
|
|
118
132
|
runOnUiThread {
|
|
119
133
|
try {
|
|
120
134
|
val id = config.getString("id") ?: throw IllegalArgumentException("Missing 'id'")
|
|
@@ -124,8 +138,10 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
124
138
|
val noHash = if (config.hasKey("noHash")) config.getBoolean("noHash") else false
|
|
125
139
|
|
|
126
140
|
this.urlConfig = UrlConfig(id, domain, language, appName, noHash = noHash)
|
|
127
|
-
|
|
128
|
-
|
|
141
|
+
// Ensure we initialize manager only once and with whatever webViewConfig is currently set
|
|
142
|
+
if (!::cmpManager.isInitialized) {
|
|
143
|
+
initializeCMPManager()
|
|
144
|
+
}
|
|
129
145
|
|
|
130
146
|
promise.resolve(null)
|
|
131
147
|
} catch (e: Exception) {
|
|
@@ -135,7 +151,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
135
151
|
}
|
|
136
152
|
|
|
137
153
|
private fun initializeCMPManager() {
|
|
138
|
-
val activity =
|
|
154
|
+
val activity = currentActivitySafe ?: throw IllegalStateException("Current activity is null")
|
|
139
155
|
Log.d("CmSdkReactNativeV3", "Initializing CMPManager with activity: $activity, delegate: $this")
|
|
140
156
|
|
|
141
157
|
cmpManager = CMPManager.getInstance(
|
|
@@ -144,6 +160,10 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
144
160
|
webViewConfig,
|
|
145
161
|
this
|
|
146
162
|
)
|
|
163
|
+
configureCmpManager(activity)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private fun configureCmpManager(activity: Activity) {
|
|
147
167
|
cmpManager.setActivity(activity)
|
|
148
168
|
|
|
149
169
|
cmpManager.setOnClickLinkCallback { url ->
|
|
@@ -166,14 +186,14 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
166
186
|
}
|
|
167
187
|
isInitialized = true
|
|
168
188
|
|
|
169
|
-
Log.d("CmSdkReactNativeV3", "CMPManager initialized with
|
|
189
|
+
Log.d("CmSdkReactNativeV3", "CMPManager initialized/reconfigured with current configs")
|
|
170
190
|
}
|
|
171
191
|
|
|
172
192
|
/**
|
|
173
193
|
* Gets the comprehensive user consent status
|
|
174
194
|
*/
|
|
175
195
|
@ReactMethod
|
|
176
|
-
|
|
196
|
+
fun getUserStatus(promise: Promise) {
|
|
177
197
|
try {
|
|
178
198
|
val userStatus = cmpManager.getUserStatus()
|
|
179
199
|
val result = Arguments.createMap().apply {
|
|
@@ -201,11 +221,16 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
201
221
|
}
|
|
202
222
|
}
|
|
203
223
|
|
|
224
|
+
private fun dpToPx(dp: Float): Float {
|
|
225
|
+
val metrics = reactApplicationContext.resources.displayMetrics
|
|
226
|
+
return android.util.TypedValue.applyDimension(android.util.TypedValue.COMPLEX_UNIT_DIP, dp, metrics)
|
|
227
|
+
}
|
|
228
|
+
|
|
204
229
|
/**
|
|
205
230
|
* Gets the consent status for a specific purpose
|
|
206
231
|
*/
|
|
207
232
|
@ReactMethod
|
|
208
|
-
|
|
233
|
+
fun getStatusForPurpose(purposeId: String, promise: Promise) {
|
|
209
234
|
try {
|
|
210
235
|
val status = cmpManager.getStatusForPurpose(purposeId)
|
|
211
236
|
promise.resolve(status.toString())
|
|
@@ -218,7 +243,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
218
243
|
* Gets the consent status for a specific vendor
|
|
219
244
|
*/
|
|
220
245
|
@ReactMethod
|
|
221
|
-
|
|
246
|
+
fun getStatusForVendor(vendorId: String, promise: Promise) {
|
|
222
247
|
try {
|
|
223
248
|
val status = cmpManager.getStatusForVendor(vendorId)
|
|
224
249
|
promise.resolve(status.toString())
|
|
@@ -231,7 +256,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
231
256
|
* Gets Google Consent Mode v2 compatible settings
|
|
232
257
|
*/
|
|
233
258
|
@ReactMethod
|
|
234
|
-
|
|
259
|
+
fun getGoogleConsentModeStatus(promise: Promise) {
|
|
235
260
|
try {
|
|
236
261
|
val consentModeStatus = cmpManager.getGoogleConsentModeStatus()
|
|
237
262
|
val result = Arguments.createMap()
|
|
@@ -250,10 +275,10 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
250
275
|
* Replacement for openConsentLayer - force opens the consent UI
|
|
251
276
|
*/
|
|
252
277
|
@ReactMethod
|
|
253
|
-
|
|
278
|
+
fun forceOpen(jumpToSettings: Boolean, promise: Promise) {
|
|
254
279
|
scope.launch {
|
|
255
280
|
try {
|
|
256
|
-
|
|
281
|
+
currentActivitySafe?.let { cmpManager.setActivity(it) }
|
|
257
282
|
|
|
258
283
|
cmpManager.forceOpen(jumpToSettings) { result ->
|
|
259
284
|
if (result.isSuccess) {
|
|
@@ -272,10 +297,10 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
272
297
|
* Replacement for checkWithServerAndOpenIfNecessary - checks with server and opens if needed
|
|
273
298
|
*/
|
|
274
299
|
@ReactMethod
|
|
275
|
-
|
|
300
|
+
fun checkAndOpen(jumpToSettings: Boolean, promise: Promise) {
|
|
276
301
|
scope.launch {
|
|
277
302
|
try {
|
|
278
|
-
|
|
303
|
+
currentActivitySafe?.let { cmpManager.setActivity(it) }
|
|
279
304
|
|
|
280
305
|
cmpManager.checkAndOpen(jumpToSettings) { result ->
|
|
281
306
|
if (result.isSuccess) {
|
|
@@ -294,7 +319,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
294
319
|
* Import a CMP information string
|
|
295
320
|
*/
|
|
296
321
|
@ReactMethod
|
|
297
|
-
|
|
322
|
+
fun importCMPInfo(cmpString: String, promise: Promise) {
|
|
298
323
|
scope.launch {
|
|
299
324
|
try {
|
|
300
325
|
cmpManager.importCMPInfo(cmpString) { result ->
|
|
@@ -314,7 +339,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
314
339
|
* Reset all consent management data
|
|
315
340
|
*/
|
|
316
341
|
@ReactMethod
|
|
317
|
-
|
|
342
|
+
fun resetConsentManagementData(promise: Promise) {
|
|
318
343
|
try {
|
|
319
344
|
cmpManager.resetConsentManagementData()
|
|
320
345
|
promise.resolve(true)
|
|
@@ -324,12 +349,12 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
324
349
|
}
|
|
325
350
|
|
|
326
351
|
@ReactMethod
|
|
327
|
-
|
|
352
|
+
fun exportCMPInfo(promise: Promise) {
|
|
328
353
|
promise.resolve(cmpManager.exportCMPInfo())
|
|
329
354
|
}
|
|
330
355
|
|
|
331
356
|
@ReactMethod
|
|
332
|
-
|
|
357
|
+
fun acceptVendors(vendors: ReadableArray, promise: Promise) {
|
|
333
358
|
scope.launch {
|
|
334
359
|
try {
|
|
335
360
|
Log.d("CmSdkReactNativeV3", "Accepting vendors: $vendors")
|
|
@@ -348,7 +373,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
348
373
|
}
|
|
349
374
|
|
|
350
375
|
@ReactMethod
|
|
351
|
-
|
|
376
|
+
fun rejectVendors(vendors: ReadableArray, promise: Promise) {
|
|
352
377
|
scope.launch {
|
|
353
378
|
try {
|
|
354
379
|
Log.d("CmSdkReactNativeV3", "Rejecting vendors: $vendors")
|
|
@@ -366,7 +391,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
366
391
|
}
|
|
367
392
|
|
|
368
393
|
@ReactMethod
|
|
369
|
-
|
|
394
|
+
fun acceptPurposes(purposes: ReadableArray, updatePurpose: Boolean, promise: Promise) {
|
|
370
395
|
scope.launch {
|
|
371
396
|
try {
|
|
372
397
|
Log.d("Cmsdkreactnativev3", "Rejecting purposes: $purposes")
|
|
@@ -385,7 +410,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
385
410
|
}
|
|
386
411
|
|
|
387
412
|
@ReactMethod
|
|
388
|
-
|
|
413
|
+
fun rejectPurposes(purposes: ReadableArray, updateVendor: Boolean, promise: Promise) {
|
|
389
414
|
scope.launch {
|
|
390
415
|
try {
|
|
391
416
|
Log.d("Cmsdkreactnativev3", "Rejecting purposes: $purposes")
|
|
@@ -403,7 +428,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
403
428
|
}
|
|
404
429
|
|
|
405
430
|
@ReactMethod
|
|
406
|
-
|
|
431
|
+
fun rejectAll(promise: Promise) {
|
|
407
432
|
scope.launch {
|
|
408
433
|
try {
|
|
409
434
|
cmpManager.rejectAll { result ->
|
|
@@ -420,7 +445,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
420
445
|
}
|
|
421
446
|
|
|
422
447
|
@ReactMethod
|
|
423
|
-
|
|
448
|
+
fun acceptAll(promise: Promise) {
|
|
424
449
|
scope.launch {
|
|
425
450
|
try {
|
|
426
451
|
cmpManager.acceptAll { result ->
|
|
@@ -451,7 +476,7 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
451
476
|
override fun onHostResume() {
|
|
452
477
|
if (::cmpManager.isInitialized) {
|
|
453
478
|
cmpManager.onApplicationResume()
|
|
454
|
-
|
|
479
|
+
currentActivitySafe?.let { cmpManager.setActivity(it) }
|
|
455
480
|
}
|
|
456
481
|
}
|
|
457
482
|
|
|
@@ -469,8 +494,9 @@ class CmSdkReactNativeV3Module(reactContext: ReactApplicationContext) :
|
|
|
469
494
|
|
|
470
495
|
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
471
496
|
Log.d("CmSdkReactNativeV3", "sendEvent called: $eventName")
|
|
472
|
-
|
|
473
|
-
|
|
497
|
+
reactApplicationContext
|
|
498
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
499
|
+
.emit(eventName, params)
|
|
474
500
|
}
|
|
475
501
|
|
|
476
502
|
private fun List<String>.toWritableArray(): WritableArray {
|
|
@@ -1,37 +1,14 @@
|
|
|
1
1
|
package com.cmsdkreactnativev3
|
|
2
2
|
|
|
3
|
-
import com.facebook.react.TurboReactPackage
|
|
4
3
|
import com.facebook.react.bridge.NativeModule
|
|
5
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.
|
|
7
|
-
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
5
|
+
import com.facebook.react.ReactPackage
|
|
8
6
|
import com.facebook.react.uimanager.ViewManager
|
|
9
7
|
|
|
10
|
-
class CmSdkReactNativeV3Package :
|
|
11
|
-
override fun
|
|
12
|
-
|
|
13
|
-
CmSdkReactNativeV3Module(reactContext)
|
|
14
|
-
} else {
|
|
15
|
-
null
|
|
16
|
-
}
|
|
17
|
-
}
|
|
8
|
+
class CmSdkReactNativeV3Package : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
|
|
10
|
+
listOf(CmSdkReactNativeV3Module(reactContext))
|
|
18
11
|
|
|
19
|
-
override fun
|
|
20
|
-
|
|
21
|
-
mapOf(
|
|
22
|
-
CmSdkReactNativeV3Module.NAME to ReactModuleInfo(
|
|
23
|
-
_name = CmSdkReactNativeV3Module.NAME,
|
|
24
|
-
_className = CmSdkReactNativeV3Module.NAME,
|
|
25
|
-
_canOverrideExistingModule = false,
|
|
26
|
-
_needsEagerInit = false,
|
|
27
|
-
isCxxModule = false,
|
|
28
|
-
isTurboModule = true
|
|
29
|
-
)
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
35
|
-
return emptyList()
|
|
36
|
-
}
|
|
12
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
|
13
|
+
emptyList()
|
|
37
14
|
}
|
|
@@ -1,80 +1,81 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
2
|
#import <React/RCTEventEmitter.h>
|
|
3
3
|
|
|
4
|
+
// Swift method declarations - bridges Swift methods to Objective-C
|
|
4
5
|
@interface RCT_EXTERN_MODULE(CmSdkReactNativeV3, RCTEventEmitter)
|
|
5
6
|
|
|
6
7
|
// Core methods
|
|
7
8
|
RCT_EXTERN_METHOD(setUrlConfig:(NSDictionary *)config
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
10
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
10
11
|
|
|
11
12
|
RCT_EXTERN_METHOD(setWebViewConfig:(NSDictionary *)config
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
14
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
14
15
|
|
|
15
16
|
RCT_EXTERN_METHOD(setATTStatus:(NSInteger)status
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
18
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
18
19
|
|
|
19
|
-
//
|
|
20
|
+
// Main methods
|
|
20
21
|
RCT_EXTERN_METHOD(checkAndOpen:(BOOL)jumpToSettings
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
23
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
23
24
|
|
|
24
25
|
RCT_EXTERN_METHOD(forceOpen:(BOOL)jumpToSettings
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
27
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
27
28
|
|
|
28
29
|
RCT_EXTERN_METHOD(getUserStatus:(RCTPromiseResolveBlock)resolve
|
|
29
|
-
|
|
30
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
30
31
|
|
|
31
32
|
RCT_EXTERN_METHOD(getStatusForPurpose:(NSString *)purposeId
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
34
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
34
35
|
|
|
35
36
|
RCT_EXTERN_METHOD(getStatusForVendor:(NSString *)vendorId
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
38
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
38
39
|
|
|
39
40
|
RCT_EXTERN_METHOD(getGoogleConsentModeStatus:(RCTPromiseResolveBlock)resolve
|
|
40
|
-
|
|
41
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
41
42
|
|
|
42
43
|
RCT_EXTERN_METHOD(exportCMPInfo:(RCTPromiseResolveBlock)resolve
|
|
43
|
-
|
|
44
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
44
45
|
|
|
45
46
|
// Consent modification methods
|
|
46
47
|
RCT_EXTERN_METHOD(acceptVendors:(NSArray *)vendors
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
49
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
49
50
|
|
|
50
51
|
RCT_EXTERN_METHOD(rejectVendors:(NSArray *)vendors
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
53
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
53
54
|
|
|
54
55
|
RCT_EXTERN_METHOD(acceptPurposes:(NSArray *)purposes
|
|
55
56
|
updatePurpose:(BOOL)updatePurpose
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
58
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
58
59
|
|
|
59
60
|
RCT_EXTERN_METHOD(rejectPurposes:(NSArray *)purposes
|
|
60
61
|
updateVendor:(BOOL)updateVendor
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
63
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
63
64
|
|
|
64
65
|
RCT_EXTERN_METHOD(rejectAll:(RCTPromiseResolveBlock)resolve
|
|
65
|
-
|
|
66
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
66
67
|
|
|
67
68
|
RCT_EXTERN_METHOD(acceptAll:(RCTPromiseResolveBlock)resolve
|
|
68
|
-
|
|
69
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
69
70
|
|
|
70
71
|
RCT_EXTERN_METHOD(importCMPInfo:(NSString *)cmpString
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
73
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
73
74
|
|
|
74
75
|
RCT_EXTERN_METHOD(resetConsentManagementData:(RCTPromiseResolveBlock)resolve
|
|
75
|
-
|
|
76
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
76
77
|
|
|
77
|
-
// Event emitter support methods
|
|
78
|
+
// Event emitter support methods
|
|
78
79
|
RCT_EXTERN_METHOD(addListener:(NSString *)eventName)
|
|
79
80
|
RCT_EXTERN_METHOD(removeListeners:(double)count)
|
|
80
81
|
|