Skip to main content

Custom Windows WebView

The default Unity Web Browser (UWB) doesn’t support IL2CPP. For IL2CPP builds or more control, integrate a third-party WebView.

Vuplex Integration

Vuplex is a commercial WebView that supports IL2CPP.

1. Install Vuplex

  1. Purchase Vuplex Windows WebView
  2. Import the .unitypackage from your Vuplex dashboard
  3. Include Core/ and Standalone/ directories (skip Mac/)

2. Implement the Interface

Create a class implementing IWindowsWebBrowserClient:
#if UNITY_STANDALONE_WIN

using Cysharp.Threading.Tasks;
using Immutable.Browser.Core;
using Vuplex.WebView;

public class VuplexWebView : IWindowsWebBrowserClient
{
    public event OnUnityPostMessageDelegate OnUnityPostMessage;
    private IWebView webView;

    public VuplexWebView()
    {
        webView = Web.CreateWebView();
    }

    public async UniTask Init()
    {
        await webView.Init(1, 1);

        webView.MessageEmitted += (sender, eventArgs) =>
        {
            OnUnityPostMessage?.Invoke(eventArgs.Value);
        };
    }

    public void LoadUrl(string url)
    {
        webView.LoadUrl(url);
    }

    public async void ExecuteJavaScript(string js)
    {
        await webView.ExecuteJavaScript(js);
    }

    public string GetPostMessageApiCall()
    {
        return "window.vuplex.postMessage";
    }

    public void Dispose()
    {
        webView.Dispose();
    }
}

#endif

3. Initialize with Custom WebView

passport = await Passport.Init(clientId, environment
#if UNITY_STANDALONE_WIN || (UNITY_EDITOR_WIN && UNITY_STANDALONE_WIN)
    , windowsWebBrowserClient: new VuplexWebView()
#endif
);

4. Configure Scripting Defines

  1. Go to FileBuild SettingsPlayer Settings
  2. Navigate to PlayerOther Settings
  3. Add IMMUTABLE_CUSTOM_BROWSER to Scripting Define Symbols
  4. Click Apply
This excludes the default WebView from your build.

5. Exclude Vuplex from Non-Windows Builds

Follow Vuplex’s platform exclusion guide to prevent Vuplex from being included in non-Windows builds.

Custom Timeout Configuration

Override default timeouts for SDK operations:
// Set custom timeout (default is 60 seconds)
passport.SetCallTimeout(TimeSpan.FromMinutes(2));

Session Persistence

The SDK automatically persists sessions. To manually control:
// Check for existing session
bool hasSession = await passport.HasCredentialsSaved();

if (hasSession)
{
    // Silent login (no UI)
    await passport.Login(useCachedSession: true);
}
else
{
    // Full login flow
    await passport.Login();
}

Logging

The Passport SDK provides logging so you can monitor and troubleshoot its behaviour. You can set the log level and optionally redact sensitive data from logs.

Log level

Use the LogLevel property to control the severity of logged messages. The default is LogLevel.Info.
LevelDescription
LogLevel.DebugDetailed information for debugging
LogLevel.InfoGeneral SDK operation information (default)
LogLevel.WarnWarnings about potential issues
LogLevel.ErrorErrors indicating SDK failures
// Set log level to Debug for verbose output
Passport.LogLevel = LogLevel.Debug;

Redacting sensitive tokens in logs

By default, access and ID tokens are logged in full. Set RedactTokensInLogs to true to replace them with [REDACTED] in log output.
Passport.RedactTokensInLogs = true;
Use this when debugging or sharing logs to avoid exposing sensitive data.

Next Steps