Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 3 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions android/src/main/java/io/didomi/reactnative/DidomiModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = mutableSetOf()
Expand Down Expand Up @@ -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()

Expand Down
5 changes: 4 additions & 1 deletion android/src/main/java/io/didomi/reactnative/EventTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
12 changes: 11 additions & 1 deletion ios/RNDidomi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion react-native-didomi.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/DidomiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -178,6 +180,11 @@ export interface SyncReadyEvent {
syncAcknowledged: () => Promise<boolean>;
}

export interface IntegrationErrorEvent {
integrationName: string;
reason: string;
}

export interface UserAuth {
id: string;
}
Expand Down
6 changes: 3 additions & 3 deletions test/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand Down
3 changes: 2 additions & 1 deletion test/ios/DidomiUITests/DidomiUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
15 changes: 5 additions & 10 deletions test/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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(() => {
Expand Down