IWithSettableUserAgent

interface

Namespace: Vuplex.WebView

An interface implemented by a webview if it supports changing the User-Agent of an individual webview instance.

Example

await webViewPrefab.WaitUntilInitialized();
var webViewWithUserAgent = webViewPrefab.WebView as IWithSettableUserAgent;
if (webViewWithUserAgent) {
    // Set a flag indicating a mobile User-Agent.
    webViewWithUserAgent.SetUserAgent(true);
    // OR set a custom User-Agent string.
    webViewWithUserAgent.SetUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0");
}

Summary

Public methods

SetUserAgent

void SetUserAgent(bool mobile)

By default, a webview uses a User-Agent of a desktop computer so that servers return the desktop versions of websites. If you instead want the mobile versions of websites, you can invoke this method with the value true to configure the webview instance to use a User-Agent of a mobile device.

SetUserAgent

void SetUserAgent(string userAgent)

Configures the webview instance to use a custom User-Agent string.