Skip to content

feat: Expose widgets APIs - #128

Merged
nicolas-chaix-didomi merged 5 commits into
masterfrom
feat/7004-widget-apis
Oct 12, 2026
Merged

nicolas-chaix-didomi merged 5 commits into
masterfrom
feat/7004-widget-apis

Conversation

@nicolas-chaix-didomi

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

Copy link
Copy Markdown
Contributor

Summary

Expose the native widgets.* APIs to Unity apps (CMP-7004), mirroring the React Native bridge (CMP-7002).

  • ShowWidget(DidomiWidgetParameters parameters = null): optional widget ID and layer name; when omitted, the widget and layer are selected by the Rules Engine
  • HideWidget()
  • IsWidgetVisible(string widgetId = null): when no ID is given, any displayed widget matches

The ShowWidget / HideWidget events were already bridged.

Implementation notes

  • No native SDK bump needed: Android 2.50.1 and iOS 2.50.0 already ship these APIs.
  • Android: show/hide call the native methods directly, like ShowNotice/ShowPreferences. The native SDK already handles threading (the JavaScript is posted to the main looper, the widget host is a fragment commit).
  • iOS: if the SDK is not ready, the native SDK defers the call until it is. On Android the native call throws DidomiNotReadyException to the caller instead, like the other methods. This is documented on ShowWidget.
  • Unity Editor: stubs that log the call and report no widget visible.
  • .gitignore: ignore Unity test runner scenes, gradle template backups, the downloaded Didomi.xcframework, .utmp, *.slnx and source/artifacts.

Tests

WidgetsTestsSuite covers the no-widget case with the test notice: show/hide are ignored, no widget event is triggered and IsWidgetVisible returns false. Testing a displayed widget would need a notice with widgets and Web SDK rendering enabled.

  • Android (emulator): 53/54 passed, including the 3 new widget tests (run before the refactor that removed the UI thread helper). The failure is AAABeforeSDKInitTestsSuite.TestSyncBeforeInit, which depends on a backend sync response and doesn't touch this code.
  • iOS: compiles; the test run on device/simulator was not completed.

Bridge the native widget APIs to Unity:
- ShowWidget(parameters?) with optional widget ID and layer name, the
  widget is selected by the Rules Engine when no ID is provided
- HideWidget()
- IsWidgetVisible(widgetId?)

Add the DidomiWidgetParameters class and the Unity Editor stubs. On
Android, show/hide run on the UI thread since the native SDK drives a
WebView.
Cover the behavior when no widget is configured: show and hide are ignored, no widget event is triggered and IsWidgetVisible returns false.
- Ignore Unity test runner scenes, gradle template backups and the
  downloaded Didomi.xcframework in source/.gitignore, after the rule
  that re-includes .meta files so their .meta files are ignored too
- Ignore .utmp, *.slnx, source/artifacts and packages-lock.json
@nicolas-chaix-didomi nicolas-chaix-didomi changed the title Expose widgets APIs (CMP-7004) feat: Expose widgets APIs Oct 7, 2026
Comment thread source/Assets/Plugins/Didomi/Scripts/Didomi.cs
Comment thread source/Assets/Plugins/Didomi/Scripts/Didomi.cs
Comment thread source/Assets/Plugins/Didomi/Scripts/Android/AndroidDidomi.cs Outdated
The native SDK already handles threading for showWidget and hideWidget:
hiding posts the JavaScript to the main looper and showing commits a
fragment, like showNotice. Drop the UI thread helper and call the native
methods directly like ShowNotice and ShowPreferences, so a not-ready
exception reaches the caller instead of only being logged.
@nicolas-chaix-didomi
nicolas-chaix-didomi merged commit 57d9736 into master Oct 12, 2026
@nicolas-chaix-didomi
nicolas-chaix-didomi deleted the feat/7004-widget-apis branch October 12, 2026 07:43
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