Skip to content

Expose showWidget, hideWidget and isWidgetVisible - #192

Open
nicolas-chaix-didomi wants to merge 6 commits into
mainfrom
feat/7002-widget-apis
Open

nicolas-chaix-didomi wants to merge 6 commits into
mainfrom
feat/7002-widget-apis

Conversation

@nicolas-chaix-didomi

@nicolas-chaix-didomi nicolas-chaix-didomi commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

CMP-7002

  • Add showWidget({ widgetId?, layerName? }), hideWidget() and isWidgetVisible(widgetId?) to the RN bridge, mirroring the native iOS/Android APIs (available since 2.47.0 / 2.50.0). Without a widgetId, the widget is selected by the Rules Engine.
  • Export the DidomiWidgetParameters type, add the old architecture stubs and Jest tests.
  • Document that SHOW_WIDGET is emitted for each layer of a widget: navigating inside the same widget (e.g. notice → purposes → back) emits on_show_widget again with the new layerName, without on_hide_widget in between. The widget is closed only on on_hide_widget.
  • Test app: add widget calls and an "Initialize widget notice" button using a local config with widgets (didomi_config_widgets.json), so tests don't depend on geolocation. Add iOS/Android UI tests asserting the on_show_widget event.
  • Sample app: add widget buttons.

Note: the UI tests only check the show event for now. With the current native SDKs, a single showWidget call leads to a shown → hidden → shown sequence from the Web SDK. On iOS, isWidgetVisible then returns false while the widget is displayed and hideWidget ends with on_show_notice. On Android, the second show fails with androidInterface.onWidgetShown is not a function.

The fixes are in progress:

  • JS bridge (sdk-shared-scripts): fix/ignore-widget-events-during-init
  • Android: fix/widget-host-webview-caching
  • iOS: fix/widget-host-show-notice-event

With these, the full flow (show → isWidgetVisible == true → hide → on_hide_widget → isWidgetVisible == false) passes locally on both platforms. The isWidgetVisible/on_hide_widget assertions will be added to the UI tests once the native SDKs including the fixes are released.

Bridge the native widget APIs available since Didomi SDK 2.47.0/2.50.0:
- showWidget(parameters?) with optional widgetId and layerName, the widget
  is selected by the Rules Engine when no ID is provided
- hideWidget()
- isWidgetVisible(widgetId?)

Add the DidomiWidgetParameters type, the old architecture stubs and Jest tests.
Add showWidget, hideWidget and isWidgetVisible calls to the test app and an
"Initialize widget notice" button using a local configuration with widgets
(didomi_config_widgets.json) so the tests do not depend on geolocation.

The UI tests only check the on_show_widget event for now: the native SDKs
currently hide and show the widget again after a single showWidget call,
which breaks isWidgetVisible and hideWidget.
UiThreadUtil.runOnUiThread posts the block, so exceptions thrown inside it
(e.g. DidomiNotReadyException when called before the SDK is ready) escaped
the surrounding try/catch and crashed the app on the UI thread, after the
promise had already been resolved.

The try/catch and the promise resolution now run inside the UI thread block
for setupUI, showNotice, forceShowNotice, showPreferences, showWidget and
hideWidget.
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