Skip to content

Support new showWidget and hideWidget events - #157

Merged
nicolas-chaix-didomi merged 3 commits into
mainfrom
feat/handle-new-widgets-events
Aug 4, 2026
Merged

Support new showWidget and hideWidget events#157
nicolas-chaix-didomi merged 3 commits into
mainfrom
feat/handle-new-widgets-events

Conversation

@nicolas-chaix-didomi

@nicolas-chaix-didomi nicolas-chaix-didomi commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Native SDKs 2.47.0 add ShowWidgetEvent / HideWidgetEvent, emitted by the Web SDK when a widget is displayed or hidden. This bridges them to Flutter.

This PR unblocks the Android build. DidomiEventListener declares showWidget/hideWidget as abstract methods with no default bodies, so the plugin does not compile against native 2.47.0 until these overrides exist:

DidomiEventStreamHandler.kt:13:1 Class 'DidomiEventStreamHandler' is not abstract
and does not implement abstract members:
fun hideWidget(event: HideWidgetEvent): Unit
fun showWidget(event: ShowWidgetEvent): Unit

iOS uses closure properties with defaults, so it compiled silently and simply never delivered the events.

Implementation notes

  • onShowWidget carries a ShowWidgetEvent with nullable widgetId and layerName; both are genuinely null at runtime (emitted as payload?.widgetId).
  • onHideWidget is a no-arg callback — HideWidgetEvent carries no data on either platform, so a Dart wrapper class would be dead weight.
  • iOS names the property widgetID, Android names it widgetId. The wire key is normalised to widgetId so a single Dart lookup works on both platforms.
  • Payload fields are read with as String? rather than .toString(): Android sends explicit nulls while iOS drops nil keys entirely, and .toString() would turn either into the literal string "null". There is an inline comment so this is not "fixed" back into consistency with the surrounding cases.

Also included

A second commit updates a stale assertion in purpose_test: IAB GVL v169 renamed special feature 2 from "Actively scan device characteristics for identification" to "Identify devices based on information actively requested". The purpose IDs are unchanged, so only the display name needed updating. This failure pre-existed this PR — it is included here so CI is green.

Verification

Check Result
flutter analyze (plugin + example) No issues
Android APK build Green — was failing before this PR
pod lib lint vs real 2.47.0 XCFramework didomi_sdk passed validation
integration_test/widget_events_test.dart Passed
integration_test/purpose_test.dart Passed after the GVL fix
Full integration suite 156 passed

Test limitation

Widget events originate in a WebView-rendered experience, and the example app's configuration serves a natively rendered notice with no widget — and there is no Dart-side API to trigger one. The integration test therefore covers listener registration, undisturbed event flow, and absence of spurious widget events, not real event delivery. This is documented in the test's header comment.

Manual verification steps are listed there too. The iOS run is the important one — it is the only check that catches a widgetID/widgetId mistake, which otherwise surfaces as a silent null.

Follow-up

A separate branch (fix/event-name-mismatches, not yet pushed) fixes DCS and SPI events that never reached Flutter listeners due to wire-string mismatches between the native handlers and the Dart event handler.

Native SDKs 2.47.0 introduce ShowWidgetEvent and HideWidgetEvent, emitted
by the Web SDK when a widget is displayed or hidden. Bridge them to Flutter:

- Android: DidomiEventListener declares showWidget/hideWidget as abstract, so
  the plugin did not compile against 2.47.0 until these overrides were added.
- iOS: the SDK names the payload property `widgetID` while Android names it
  `widgetId`; the wire key is normalised to `widgetId` so a single Dart
  lookup works on both platforms.
- Dart: onShowWidget carries a ShowWidgetEvent with nullable widgetId and
  layerName. Both are read with an `as String?` cast rather than toString(),
  because Android sends explicit nulls and iOS omits nil keys entirely, and
  toString() would turn either into the literal string "null".
- onHideWidget is a no-arg callback since HideWidgetEvent carries no data.

Widget events originate in a WebView-rendered experience and the example
app's configuration serves a native notice, so the integration test covers
listener registration and absence of regressions rather than real event
delivery; the limitation is documented in the test.
IAB GVL v169 renamed special feature 2 from "Actively scan device
characteristics for identification" to "Identify devices based on
information actively requested", which broke the expected purpose names in
purpose_test. The purpose IDs are unchanged, so only the display name
assertion needed updating.
Comment thread example/lib/events_helper.dart
Comment thread CHANGELOG.md Outdated
@nicolas-chaix-didomi
nicolas-chaix-didomi merged commit f709be2 into main Aug 4, 2026
7 checks passed
@nicolas-chaix-didomi
nicolas-chaix-didomi deleted the feat/handle-new-widgets-events branch August 4, 2026 13:11
nicolas-chaix-didomi added a commit to didomi/react-native that referenced this pull request Aug 4, 2026
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.
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.

3 participants