`IWebBrowserSchemeHandler` support for Android and iOS

Our game requires that we provide an API for embedded web apps to interact with game data. We’d like a portion of this API to be authored as custom URL schemes that can be authored in HTML, for example - `<img src=“my-game://image/{contentId}” />` would allow C++ game code to look up the corresponding asset and stream an image to the browser.

This works well on Win64 by implementing the `IWebBrowserSchemeHandler` and `IWebBrowserSchemeHandlerFactory` APIs, but unfortunately these aren’t implemented on Android and iOS.

The workaround for mobile is to either pass Base64 strings to the web page (expensive for CPU and memory) or use `file://` origins (security/CORS issues on mobile).

In `WebBrowserSingleton.cpp`, the implementation for `RegisterSchemeHandlerFactory` is wrapped with an `#if WITH_CEF3` block. On mobile platforms, the native web view wrappers don’t consult the engine’s scheme registery, making it impossible to intercept and serve local binary data directly to a web page via a custom scheme.

Locally we’ve been able to modify the various browser-related classes to enable this natively:

  1. Remove the `#if WITH_CEF3` guard in `WebBrowserSingleton.cpp` and expose a lookup API for platform-specific widgets to query registered factories
  2. Patched `SAndroidWebBrowserWidget::HandleShouldInterceptRequest` to check the scheme against the C++ registry, execute the `IWebBrowserSchemeHandler` and stream the results back into the JNI `WebResourceResponse`
  3. We haven’t implemented this locally yet, but we plan to use the `WKURLSchemeHandler` protocol in `ApplePlatformWebBrowser.cpp` to bridge the native `WKWebView` requests back to the C++ registery

Before we continue investing more into this, I wanted to check to see if there are there plans on Epic side to eventually implement this behavior natively for mobile web views?

[Attachment Removed]

Steps to Reproduce

  1. Create a Custom Scheme Handler: Implement IWebBrowserSchemeHandler and IWebBrowserSchemeHandlerFactory in C++ and register it via IWebBrowserSingleton::RegisterSchemeHandlerFactory(TEXT(“my-game”), TEXT(“”), myFactory).
  2. Verify on Desktop: Run the project on Win64/macOS. Point a UWebBrowser widget at an HTML page containing <img src=“my-game://image/test_portrait” />. Observe that the handler is invoked and the image renders.
  3. Inspect Engine Code (The Root Cause): Observe that in WebBrowserSingleton.cpp, the registration logic is wrapped in #if WITH_CEF3. The mobile native (AndroidWebBrowserWidget.cpp and ApplePlatformWebBrowser.cpp) don’t reference the SchemeHandlerFactories map at any point during their navigation or resource-loading lifecycles.
  4. Deploy to Mobile: Package and run the same project on Android or iOS.
  5. Observe Failure: The image fails to load. On Android, the console logs typically show an “Unknown Scheme” error; on iOS, the request is either ignored or blocked by WKWebView security policies as it does not recognize the custom scheme.
    [Attachment Removed]

Hi Viet,

I discussed this with the WebBrowser devs and, unfortunately, there are no plans to pursue this internally. However, they would be open to looking at a PR if this is something you’d deem useful to longer term use of UE.

Best regards.

[Attachment Removed]