Skip to content

Commit 47c4a07

Browse files
feat: implement authId Android
1 parent f3f9f6a commit 47c4a07

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

android/src/main/java/com/sourcepoint/reactnativecmp/RNSourcepointCmpModule.kt

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.sourcepoint.reactnativecmp
22

33
import android.view.View
4-
import com.facebook.react.bridge.Arguments.createArray
54
import com.facebook.react.bridge.Arguments.createMap
65
import com.facebook.react.bridge.ReactApplicationContext
76
import com.facebook.react.bridge.ReactMethod
@@ -24,6 +23,10 @@ import com.sourcepoint.cmplibrary.util.userConsents
2423
import com.sourcepoint.reactnativecmp.consents.RNSPUserData
2524
import org.json.JSONObject
2625

26+
data class SPLoadMessageParams(val authId: String?) {
27+
constructor(fromReadableMap: ReadableMap?) : this(authId = fromReadableMap?.getString("authId"))
28+
}
29+
2730
class RNSourcepointCmpModule internal constructor(context: ReactApplicationContext) :
2831
RNSourcepointCmpSpec(context) , SpClient {
2932
enum class SDKEvent {
@@ -68,8 +71,13 @@ class RNSourcepointCmpModule internal constructor(context: ReactApplicationConte
6871
}
6972

7073
@ReactMethod
71-
override fun loadMessage() {
72-
runOnMainThread { spConsentLib?.loadMessage(View.generateViewId()) }
74+
override fun loadMessage(params: ReadableMap?) {
75+
val parsedParams = SPLoadMessageParams(fromReadableMap = params)
76+
77+
runOnMainThread { spConsentLib?.loadMessage(
78+
authId = parsedParams.authId,
79+
cmpViewId = View.generateViewId()
80+
) }
7381
}
7482

7583
@ReactMethod

android/src/oldarch/RNSourcepointCmpSpec.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ abstract class RNSourcepointCmpSpec internal constructor(context: ReactApplicati
99
ReactContextBaseJavaModule(context) {
1010

1111
abstract fun build(accountId: Int, propertyId: Int, propertyName: String, campaigns: ReadableMap)
12-
abstract fun loadMessage()
12+
abstract fun loadMessage(params: ReadableMap?)
1313
abstract fun clearLocalData()
1414
abstract fun getUserData(promise: Promise)
1515
abstract fun loadGDPRPrivacyManager(pmId: String)

0 commit comments

Comments
 (0)