Skip to content

feat: add showWidget and hideWidget events - #125

Merged
nicolas-chaix-didomi merged 2 commits into
masterfrom
feat/show-hide-widget-events
Aug 4, 2026
Merged

feat: add showWidget and hideWidget events#125
nicolas-chaix-didomi merged 2 commits into
masterfrom
feat/show-hide-widget-events

Conversation

@nicolas-chaix-didomi

Copy link
Copy Markdown
Contributor

Updates the native SDKs to 2.47.0 and exposes the new widget events, mirroring didomi/react-native#186.

Changes

Native SDKs → 2.47.0

  • iosNativeVersion and androidNativeVersion in Resources/package.json. That file is the single source of truth: DidomiPaths builds the XCFramework download URL from it, and PostProcessor injects the Android dependency from it, so there are no other version pins to update.
  • Plugin version → 2.29.0 (same file, also used for the SDK user agent on both platforms)

Widget events

  • New ShowWidgetEvent (widgetId, layerName) and HideWidgetEvent, exposed as ShowWidget / HideWidget on DidomiEventListener
  • Android: showWidget / hideWidget in EventListenerProxy.cs, with a ConvertToShowWidgetEvent helper following the existing integrationError pattern
  • iOS: DDMEventTypeShowWidget / DDMEventTypeHideWidget, onShowWidget / onHideWidget closures in Didomi.mm, and a new OnShowWidgetEventListenerDelegate P/Invoke callback in DidomiFramework.cs
  • Events registered in the sample app (DemoGUI.cs)

Two things worth a reviewer's attention

The iOS enum is not contiguous. The native values are 47 and 48, not 44/45 — slots 44 to 46 belong to ConsentChangedWithObject and two UI events that Unity does not expose. The iOS header carries the note "Please keep the current order because of Unity bridge." Appending sequentially would have compiled fine and silently misrouted events at runtime, so the values were read off the real 2.47.0 header. A comment in DDMEventType.cs records why the gap is there.

Android's proxy has a hard runtime contract. AndroidJavaProxy requires every method of the Java interface to be implemented, so showWidget / hideWidget were not optional once the SDK moved to 2.47.0 — omitting them would break the whole listener.

Cross-platform naming

The iOS SDK exposes the property as widgetID, Android as widgetId. Both bridges map it to widgetId so a single C# event class fits both platforms. Noted in a comment at each site, same approach as the React Native PR.

Since showWidget carries two strings it uses a dedicated callback, like integrationError. hideWidget has no payload and reuses the generic handler.

Verification

  • Unity 6000.3.5f1 batchmode compile: clean, no errors. The new types, the add_ / remove_ accessors for both events, and the new P/Invoke callback are all present in the compiled DidomiAssembly.dll.
  • iOS: Didomi.mm passes clang -fsyntax-only against the real 2.47.0 XCFramework headers with no errors and no warnings, confirming onShowWidget, onHideWidget and the widgetID property.
  • Android: EventListenerProxy implements all 46 methods of the 2.47.0 DidomiEventListener interface, verified against the published AAR.

Not covered by automated tests

End-to-end event delivery needs a web-rendered notice that actually serves a widget, and the existing suites are on-device integration tests with no API to trigger one — so no test was added that would assert nothing. Same limitation documented in the React Native and Flutter PRs. Worth a manual check against a widget-serving notice configuration before release.

Update the native SDKs to 2.47.0 and expose the new widget events,
mirroring didomi/react-native#186.

Native SDKs -> 2.47.0
- iosNativeVersion and androidNativeVersion in package.json, which is the
  single source of truth for both the XCFramework download and the Android
  dependency injected at build time.

Widget events
- New ShowWidgetEvent (widgetId, layerName) and HideWidgetEvent classes,
  exposed as ShowWidget / HideWidget on DidomiEventListener.
- Android: showWidget / hideWidget implementations in EventListenerProxy.
  AndroidJavaProxy requires every method of the Java interface to be
  implemented, so both are mandatory with the 2.47.0 SDK.
- iOS: DDMEventTypeShowWidget / DDMEventTypeHideWidget mapped to the native
  values 47 and 48. Values 44 to 46 belong to events not exposed in Unity, so
  the enum is not contiguous here.
- iOS showWidget carries two strings, so it uses a dedicated callback like
  integrationError. hideWidget has no payload and reuses the generic handler.
- Events registered in the sample app.

Cross-platform naming: the iOS SDK exposes the property as widgetID and
Android as widgetId. Both bridges map it to widgetId so a single C# event
class fits both platforms, as done in the React Native PR.

Verification
- Unity 6000.3.5f1 batchmode compile succeeds with no errors; the new types,
  the add_/remove_ accessors for both events and the new P/Invoke callback are
  present in the compiled DidomiAssembly.dll.
- Didomi.mm passes clang -fsyntax-only against the real 2.47.0 XCFramework
  headers with no errors or warnings, confirming onShowWidget, onHideWidget
  and the widgetID property.
- EventListenerProxy implements all 46 methods of the 2.47.0
  DidomiEventListener Java interface, verified against the published AAR.

Not covered by automated tests: end-to-end delivery needs a web-rendered
notice that actually serves a widget, and the existing suites are on-device
integration tests with no API to trigger one. Same limitation as the React
Native and Flutter PRs, so this is worth a manual check against a
widget-serving notice before release.
@nicolas-chaix-didomi
nicolas-chaix-didomi merged commit 017e965 into master Aug 4, 2026
@nicolas-chaix-didomi
nicolas-chaix-didomi deleted the feat/show-hide-widget-events branch August 4, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants