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..b2ba22a0 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,18 @@ 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") + 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..34623ce8 100644 --- a/ios/RNDidomi.swift +++ b/ios/RNDidomi.swift @@ -755,7 +755,9 @@ extension RNDidomi { "on_sync_error", // Language "on_language_updated", - "on_language_update_failed" + "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_integration_error", body: result) + } + Didomi.shared.addEventListener(listener: didomiEventListener) } diff --git a/react-native-didomi.podspec b/react-native-didomi.podspec index 6978d498..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.28.0" + s.dependency "Didomi-XCFramework", "2.31.1" 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/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") 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(() => {