Support new showWidget and hideWidget events - #157
Merged
Conversation
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.
pmerlet-at-didomi
previously approved these changes
Aug 3, 2026
felipe-saez
reviewed
Aug 3, 2026
pmerlet-at-didomi
approved these changes
Aug 4, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
DidomiEventListenerdeclaresshowWidget/hideWidgetas abstract methods with no default bodies, so the plugin does not compile against native 2.47.0 until these overrides exist:iOS uses closure properties with defaults, so it compiled silently and simply never delivered the events.
Implementation notes
onShowWidgetcarries aShowWidgetEventwith nullablewidgetIdandlayerName; both are genuinely null at runtime (emitted aspayload?.widgetId).onHideWidgetis a no-arg callback —HideWidgetEventcarries no data on either platform, so a Dart wrapper class would be dead weight.widgetID, Android names itwidgetId. The wire key is normalised towidgetIdso a single Dart lookup works on both platforms.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
flutter analyze(plugin + example)pod lib lintvs real 2.47.0 XCFrameworkdidomi_sdk passed validationintegration_test/widget_events_test.dartintegration_test/purpose_test.dartTest 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/widgetIdmistake, 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.