From eb0fc994c840fa67a35ecdbf90913898816ab637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phile=CC=81mon=20Merlet?= Date: Thu, 9 Oct 2025 10:17:24 +0200 Subject: [PATCH 1/5] Update native SDKs + Handle integration error events --- android/build.gradle | 2 +- android/gradle.properties | 6 +++--- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../java/io/didomi/reactnative/DidomiModule.kt | 18 ++++++++++++++++++ .../java/io/didomi/reactnative/EventTypes.kt | 5 ++++- ios/RNDidomi.swift | 10 ++++++++++ react-native-didomi.podspec | 2 +- src/DidomiTypes.ts | 7 +++++++ test/android/build.gradle | 6 +++--- test/src/App.tsx | 15 +++++---------- 10 files changed, 53 insertions(+), 20 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index f37878cf..c4950049 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -131,5 +131,5 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation("com.google.code.gson:gson:2.13.1") - implementation "io.didomi.sdk:android:2.28.0" + implementation "io.didomi.sdk:android:2.31.1" } diff --git a/android/gradle.properties b/android/gradle.properties index bb49d2f6..fb828ab2 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,6 +1,6 @@ Didomi_kotlinVersion=1.9.24 -Didomi_buildToolsVersion=34.0.0 -Didomi_compileSdkVersion=34 +Didomi_buildToolsVersion=35.0.0 +Didomi_compileSdkVersion=35 Didomi_minSdkVersion=21 -Didomi_targetSdkVersion=34 +Didomi_targetSdkVersion=35 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index dedd5d1e..ed4c299a 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/android/src/main/java/io/didomi/reactnative/DidomiModule.kt b/android/src/main/java/io/didomi/reactnative/DidomiModule.kt index 6a25c47a..325e8872 100644 --- a/android/src/main/java/io/didomi/reactnative/DidomiModule.kt +++ b/android/src/main/java/io/didomi/reactnative/DidomiModule.kt @@ -236,6 +236,11 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava * Language update failed */ override fun languageUpdateFailed(event: LanguageUpdateFailedEvent) = prepareEvent(EventTypes.LANGUAGE_UPDATE_FAILED.event, event.reason) + + /* + * Error while using an external SDK integration + */ + override fun integrationError(event: IntegrationErrorEvent) = prepareIntegrationErrorEvent(event) } private val vendorStatusListeners: MutableSet = mutableSetOf() @@ -1177,6 +1182,19 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava .emit(eventName, params) } + private fun prepareIntegrationErrorEvent(event: IntegrationErrorEvent) { + val eventName = EventTypes.INTEGRATION_ERROR_EVENT.event + Log.d("prepareEvent", "Sending $eventName") + println("DIDOMI: prepareEvent $eventName") + val params = WritableNativeMap().apply { + putString("integrationName", event.integrationName) + putString("reason", event.reason) + } + reactContext + .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) + .emit(eventName, params) + } + // Required to transform from array to variadic. private fun readableArrayToStringArray(readableArray: ReadableArray) = readableArray.toSet().toTypedArray() diff --git a/android/src/main/java/io/didomi/reactnative/EventTypes.kt b/android/src/main/java/io/didomi/reactnative/EventTypes.kt index 47579ccc..4dc60a4a 100644 --- a/android/src/main/java/io/didomi/reactnative/EventTypes.kt +++ b/android/src/main/java/io/didomi/reactnative/EventTypes.kt @@ -65,5 +65,8 @@ enum class EventTypes(val event: String) { LANGUAGE_UPDATE_FAILED("on_language_update_failed"), // Vendor Status - VENDOR_STATUS_CHANGE_PREFIX("on_vendor_status_change_"); + VENDOR_STATUS_CHANGE_PREFIX("on_vendor_status_change_"), + + // Integrations + INTEGRATION_ERROR_EVENT("on_integration_error") } diff --git a/ios/RNDidomi.swift b/ios/RNDidomi.swift index 1b91734d..05800958 100644 --- a/ios/RNDidomi.swift +++ b/ios/RNDidomi.swift @@ -756,6 +756,8 @@ extension RNDidomi { // Language "on_language_updated", "on_language_update_failed" + // Integrations + "on_integration_error" ]) vendorStatusListeners.forEach { eventsSet.insert("on_vendor_status_change_\($0)") @@ -937,6 +939,14 @@ extension RNDidomi { self?.dispatchEvent(withName: "on_language_update_failed", body: reason) } + didomiEventListener.onIntegrationError = { [weak self] event in + let result = [ + "integrationName": event.integrationName, + "reson": event.reason + ] + self?.dispatchEvent(withName: "on_sync_ready", body: result) + } + Didomi.shared.addEventListener(listener: didomiEventListener) } diff --git a/react-native-didomi.podspec b/react-native-didomi.podspec index 6978d498..306dec38 100644 --- a/react-native-didomi.podspec +++ b/react-native-didomi.podspec @@ -16,5 +16,5 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,mm,swift}" s.dependency "React-Core" - s.dependency "Didomi-XCFramework", "2.28.0" + s.dependency "Didomi-XCFramework", "2.31.0" end diff --git a/src/DidomiTypes.ts b/src/DidomiTypes.ts index a99bbb2f..86a93e82 100644 --- a/src/DidomiTypes.ts +++ b/src/DidomiTypes.ts @@ -75,6 +75,8 @@ export enum DidomiEventType { // Language LANGUAGE_UPDATED = "on_language_updated", LANGUAGE_UPDATE_FAILED = "on_language_update_failed", + // Integrations + INTEGRATION_ERROR = "on_integration_error", } export interface Vendor { @@ -178,6 +180,11 @@ export interface SyncReadyEvent { syncAcknowledged: () => Promise; } +export interface IntegrationErrorEvent { + integrationName: string; + reason: string; +} + export interface UserAuth { id: string; } diff --git a/test/android/build.gradle b/test/android/build.gradle index f536a792..fa2c5126 100644 --- a/test/android/build.gradle +++ b/test/android/build.gradle @@ -1,9 +1,9 @@ buildscript { ext { - buildToolsVersion = "34.0.0" + buildToolsVersion = "35.0.0" minSdkVersion = 23 - compileSdkVersion = 34 - targetSdkVersion = 34 + compileSdkVersion = 35 + targetSdkVersion = 35 ndkVersion = "26.1.10909125" kotlinVersion = "1.9.22" } diff --git a/test/src/App.tsx b/test/src/App.tsx index 9f3a8aa0..079594b2 100644 --- a/test/src/App.tsx +++ b/test/src/App.tsx @@ -75,6 +75,7 @@ function App() { //registerListener(DidomiEventType.SYNC_ERROR); registerListener(DidomiEventType.LANGUAGE_UPDATED); registerListener(DidomiEventType.LANGUAGE_UPDATE_FAILED); + registerListener(DidomiEventType.INTEGRATION_ERROR); }; React.useEffect(() => { @@ -96,16 +97,10 @@ function App() { });*/ async function init() { - await Didomi.initialize( - '9bf8a7e4-db9a-4ff2-a45c-ab7d2b6eadba', - undefined, - undefined, - undefined, - false, - undefined, - "Ar7NPQ72", - undefined - ); + await Didomi.initializeWithParameters({ + apiKey: "9bf8a7e4-db9a-4ff2-a45c-ab7d2b6eadba", + noticeId: "Ar7NPQ72" + }); console.log('Finished init'); Didomi.onReady().then(() => { From 5d7d4105ffc8ed0ac129c47db74ff06422a63f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phile=CC=81mon=20Merlet?= Date: Thu, 9 Oct 2025 16:02:12 +0200 Subject: [PATCH 2/5] Fix event on iOS --- ios/RNDidomi.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/RNDidomi.swift b/ios/RNDidomi.swift index 05800958..3a74b95f 100644 --- a/ios/RNDidomi.swift +++ b/ios/RNDidomi.swift @@ -755,7 +755,7 @@ extension RNDidomi { "on_sync_error", // Language "on_language_updated", - "on_language_update_failed" + "on_language_update_failed", // Integrations "on_integration_error" ]) @@ -941,10 +941,10 @@ extension RNDidomi { didomiEventListener.onIntegrationError = { [weak self] event in let result = [ - "integrationName": event.integrationName, + "integrationName": event.sdkName, "reson": event.reason ] - self?.dispatchEvent(withName: "on_sync_ready", body: result) + self?.dispatchEvent(withName: "on_integration_error", body: result) } Didomi.shared.addEventListener(listener: didomiEventListener) From e9555763d072aa22baf499597a108cdb5e64e38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phile=CC=81mon=20Merlet?= Date: Thu, 9 Oct 2025 18:00:06 +0200 Subject: [PATCH 3/5] Fix iOS tests --- test/ios/DidomiUITests/DidomiUITests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/ios/DidomiUITests/DidomiUITests.swift b/test/ios/DidomiUITests/DidomiUITests.swift index a4605181..f09a2064 100644 --- a/test/ios/DidomiUITests/DidomiUITests.swift +++ b/test/ios/DidomiUITests/DidomiUITests.swift @@ -207,7 +207,8 @@ class DidomiUITests: XCTestCase { tapButton(in: app, name: "showPreferences Vendors") // Check opening of vendors - let vendorsButton = app.staticTexts["Save"] + let vendorsView = app.otherElements["vendors_view"] + let vendorsButton = vendorsView.staticTexts["Save"] vendorsButton.wait() testLastEvent(app: app, name:"on_show_preferences") From da6526e9a3d8b3175da2fa01a4fcc2c99b32a9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phile=CC=81mon=20Merlet?= Date: Fri, 10 Oct 2025 10:19:31 +0200 Subject: [PATCH 4/5] Update iOS native sdk and event --- ios/RNDidomi.swift | 2 +- react-native-didomi.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RNDidomi.swift b/ios/RNDidomi.swift index 3a74b95f..34623ce8 100644 --- a/ios/RNDidomi.swift +++ b/ios/RNDidomi.swift @@ -941,7 +941,7 @@ extension RNDidomi { didomiEventListener.onIntegrationError = { [weak self] event in let result = [ - "integrationName": event.sdkName, + "integrationName": event.integrationName, "reson": event.reason ] self?.dispatchEvent(withName: "on_integration_error", body: result) diff --git a/react-native-didomi.podspec b/react-native-didomi.podspec index 306dec38..a797f22d 100644 --- a/react-native-didomi.podspec +++ b/react-native-didomi.podspec @@ -16,5 +16,5 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,mm,swift}" s.dependency "React-Core" - s.dependency "Didomi-XCFramework", "2.31.0" + s.dependency "Didomi-XCFramework", "2.31.1" end From 09738041196b8663ec51e571ae1b7594f91fb49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phile=CC=81mon=20Merlet?= Date: Fri, 10 Oct 2025 10:22:54 +0200 Subject: [PATCH 5/5] Remove unwanted log --- android/src/main/java/io/didomi/reactnative/DidomiModule.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/android/src/main/java/io/didomi/reactnative/DidomiModule.kt b/android/src/main/java/io/didomi/reactnative/DidomiModule.kt index 325e8872..b2ba22a0 100644 --- a/android/src/main/java/io/didomi/reactnative/DidomiModule.kt +++ b/android/src/main/java/io/didomi/reactnative/DidomiModule.kt @@ -1185,7 +1185,6 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava private fun prepareIntegrationErrorEvent(event: IntegrationErrorEvent) { val eventName = EventTypes.INTEGRATION_ERROR_EVENT.event Log.d("prepareEvent", "Sending $eventName") - println("DIDOMI: prepareEvent $eventName") val params = WritableNativeMap().apply { putString("integrationName", event.integrationName) putString("reason", event.reason)