Skip to content

feat: add showWidget and hideWidget events - #186

Merged
nicolas-chaix-didomi merged 1 commit into
mainfrom
feat/widget-events
Aug 4, 2026
Merged

feat: add showWidget and hideWidget events#186
nicolas-chaix-didomi merged 1 commit into
mainfrom
feat/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/flutter#157.

Changes

Native SDKs → 2.47.0

  • react-native-didomi.podspec (iOS), android/build.gradle (Android)
  • Module version → 2.32.0 (package.json, src/Constants.ts)

Widget events

  • SHOW_WIDGET (on_show_widget) and HIDE_WIDGET (on_hide_widget) added to DidomiEventType
  • New ShowWidgetEvent payload type (widgetId, layerName), exported from src/index.tsx
  • Android: showWidget / hideWidget listener overrides plus a prepareShowWidgetEvent helper in DidomiModule.kt, enum entries in EventTypes.kt
  • iOS: onShowWidget / onHideWidget handlers in RNDidomi.swift, both names added to supportedEvents
  • Events registered in the sample and test apps

DidomiListener.ts needed no change — it iterates over DidomiEventType, so it picks up both new types automatically.

Cross-platform naming

The iOS SDK exposes the property as widgetID, Android as widgetId. Both bridges normalize the wire key to widgetId so a single JS type fits both platforms. Noted in a comment at each site (same approach as the Flutter PR).

Verification

  • npm run typescript and npm test pass (14 tests, including 3 new ones covering the widget event types and their native-emitter registration)
  • Sample and test apps typecheck clean against the rebuilt lib/
  • Android compileDebugKotlin succeeds against SDK 2.47.0; verified via javap that both listener overrides are in the compiled output
  • iOS xcodebuild succeeds against pod 2.47.0 (** BUILD SUCCEEDED **)

Not covered by automated tests

End-to-end event delivery requires a web-rendered notice that actually serves a widget, and there is no JS-side API to trigger one — so real event delivery can't be produced by the example apps. This is the same limitation documented in didomi/flutter#157. Worth a manual check against a widget-serving notice configuration before release.

Update native SDKs to 2.47.0 (iOS and Android) and expose the new
widget events, mirroring didomi/flutter#157.

- Add SHOW_WIDGET / HIDE_WIDGET to DidomiEventType, with a
  ShowWidgetEvent payload type (widgetId, layerName).
- Bridge the events on both platforms. The iOS SDK names the property
  `widgetID` while Android names it `widgetId`; the event key is
  normalized to `widgetId` so the JS type matches on both platforms.
- Register the events in the sample and test apps, and cover the new
  event types in DidomiListener tests.
@nicolas-chaix-didomi
nicolas-chaix-didomi merged commit cd04b47 into main Aug 4, 2026
3 checks passed
@nicolas-chaix-didomi
nicolas-chaix-didomi deleted the feat/widget-events branch August 4, 2026 13:11
nicolas-chaix-didomi added a commit to didomi/unity that referenced this pull request Aug 4, 2026
* feat: add showWidget and hideWidget events

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.

* increment bridge version
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