### Start Snapshot For Rendering Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Begins the continuous rendering of a web view snapshot. Can optionally specify a region and a callback for when rendering starts. ```APIDOC ## POST /snapshot/rendering/start ### Description Starts the process of continually rendering the snapshot. ### Method POST ### Endpoint /snapshot/rendering/start ### Parameters #### Request Body - **rect** (Rect) - Optional - The rectangular area of the web view to render. Defaults to the entire view if null. - **onStarted** (Action) - Optional - A callback function to be executed once rendering has started. ### Request Example ```json { "rect": { "x": 0, "y": 0, "width": 800, "height": 600 }, "onStarted": "myCallbackFunction" } ``` ### Response #### Success Response (200) - **message** (string) - Indicates that snapshot rendering has started. #### Response Example ```json { "message": "Snapshot rendering started." } ``` ``` -------------------------------- ### Full UniWebView Transparency Example Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/transparency-through.md A comprehensive C# example demonstrating how to set up UniWebView for transparency clicking through. It includes initializing the web view, enabling click-through, setting a clear background, handling messages, and loading a URL. ```csharp Text passthroughText; UniWebView webView; void ShowWebView() { // Prepare Unity UI. passthroughText.text = "Sample Text"; // Create web view. webView = gameObject.AddComponent(); webView.Frame = new Rect(0, 0, Screen.width, Screen.height); // Allow transparency clicking through. webView.SetTransparencyClickingThroughEnabled(true); // Make Unity scene visible. webView.BackgroundColor = Color.clear; // Disable the scrolling bounces effect to fix the web UI. webView.SetBouncesEnabled(false); webView.OnShouldClose += (view) => { webView = null; return true; }; webView.OnMessageReceived += (view, message) => { if (message.Path == "close") { Destroy(webView); webView = null; } else if (message.Path == "hello") { passthroughText.text = "Hello From Web View"; } }; webView.Load("https://docs.uniwebview.com/passthrough.html"); webView.Show(); } void UnityCloseButtonTapped() { Destroy(webView); webView = null; } ``` -------------------------------- ### UniWebView Move Animation Example Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/transition.md Shows how to animate a UniWebView to a new position and size using the AnimateTo method. This example animates the web view to half the screen height with a specified duration and delay. ```csharp webView.Frame = new Rect(0, 0, Screen.width, Screen.height); var halfScreen = new Rect(0, 0, Screen.width, Screen.height / 2.0); // The animation will last for 400ms and with 100ms delay: webView.AnimateTo(halfScreen, 0.4f, 0.1f, ()=>{ print("Animation finished!"); }); ``` -------------------------------- ### Start Snapshot Rendering Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Starts the process of continually rendering the snapshot of the web view. This prepares a render buffer and performs initial rendering. It's a prerequisite for getting rendered data or textures. Remember to call StopSnapshotForRendering when done. ```APIDOC ## void StartSnapshotForRendering(Rect? rect = null, Action onStarted = null) ### Description Starts the process of continually rendering the snapshot. This method prepares a render buffer for image data and performs initial rendering, which is necessary before using `GetRenderedData` or `CreateRenderedTexture`. ### Method void ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **rect** (Rect?) - Optional - The area of the view to render. If null, the entire view is rendered. - **onStarted** (Action) - Optional - A callback executed when rendering starts, receiving the rendered texture. ### Request Example ```csharp // Example of starting snapshot rendering for the entire view webView.StartSnapshotForRendering(); // Example of starting snapshot rendering for a specific area with a callback Rect renderingArea = new Rect(0, 0, 100, 100); webView.StartSnapshotForRendering(renderingArea, (texture) => { Debug.Log("Snapshot rendering started. Texture created."); }); ``` ### Response #### Success Response (void) This method does not return a value. #### Response Example N/A ``` -------------------------------- ### Start Authentication Flow (C#) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationCommonFlow.md This method should be overridden by subclasses to initiate the authentication process, typically by starting a UniWebViewAuthenticationFlow or a custom implementation. It serves as the entry point for authentication. ```csharp public abstract void StartAuthenticationFlow(); ``` -------------------------------- ### Start UniWebViewAuthenticationSession Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationSession.md Starts the authentication session process, displaying a secured web page to the user. It requires a pre-created UniWebViewAuthenticationSession object and allows for handling authentication completion and errors via callbacks. ```csharp var session = UniWebViewAuthenticationSession.Create("https://example.com/oauth/authorize?client_id=12345&&scope=profile", "authExample"); session.OnAuthenticationFinished += (_, resultUrl) => { Debug.Log("Auth flow received callback url: " + resultUrl); // Continue to exchange the code to the access token. }; session.OnAuthenticationErrorReceived += (_, errorCode, message) => { // Error handling. }; ``` -------------------------------- ### Start Rendering Process for UniWebView Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/render-as-texture.md Starts the process of rendering UniWebView content into a texture. This method should be called before accessing any texture data. It does not require the web view to be visible. ```csharp public class MyBehaviour : MonoBehaviour { UniWebView webView; void OpenWebView() { webView = gameObject.AddComponent(); webView.Frame = new Rect(0, 0, Screen.width, Screen.height); webView.Load("https://uniwebview.com"); // Start the rendering process. webView.StartSnapshotForRendering(); } } ``` -------------------------------- ### Start Authentication Flow Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowGoogle.md Initiates the standard OAuth 2.0 authentication process. ```APIDOC ## void StartAuthenticationFlow() ### Description Starts the authentication flow with the standard OAuth 2.0. This implements the abstract method in `UniWebViewAuthenticationCommonFlow`. ### Method GET ### Endpoint N/A (Method call within the SDK) ### Parameters None ### Request Example ```csharp // Assuming 'googleFlow' is an instance of the authentication flow class googleFlow.StartAuthenticationFlow(); ``` ### Response #### Success Response (N/A) This method returns void and initiates an external process. #### Response Example N/A ``` -------------------------------- ### UniWebViewAuthenticationSession Start Method Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationSession.md Initiates the authentication session process. This method should be called after creating the session. ```csharp public void Start() ``` -------------------------------- ### UniWebViewAuthenticationSession Start Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationSession.md Starts the authentication session process. This action displays a secure web page to the user, directing them to the authentication URL provided during session creation. ```APIDOC ## POST /onevcat/uniwebview-docs/start ### Description Starts the authentication session process. It will show up a secured web page and navigate users to the `Url`. ### Method POST ### Endpoint /onevcat/uniwebview-docs/start ### Parameters #### Request Body - **session** (UniWebViewAuthenticationSession) - Required - The authentication session object to start. ### Request Example ```csharp var session = UniWebViewAuthenticationSession.Create("https://example.com/oauth/authorize?client_id=12345", "authExample"); session.OnAuthenticationFinished += (webView, resultUrl) => { Debug.Log("Auth flow received callback url: " + resultUrl); }; session.OnAuthenticationErrorReceived += (webView, errorCode, message) => { Debug.LogError($"Auth error: {errorCode} - {message}"); }; // In a real API call, you would send the session object or its identifier // For documentation purposes, we'll represent the action of starting a pre-created session. ``` ### Response #### Success Response (200) - **message** (string) - Indicates that the authentication session has been successfully initiated. #### Response Example ```json { "message": "Authentication session started successfully." } ``` ``` -------------------------------- ### UniWebView Show/Hide Transition Example Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/transition.md An example of how to call the Show and Hide methods with fade and edge transitions enabled. This shows a bottom edge transition with fading. Only one transition can occur at a time. ```csharp webView.Frame = new Rect(0, 0, Screen.width, Screen.height); webView.Show(true, UniWebViewTransitionEdge.Bottom, 0.35f); // Later webView.Hide(true, UniWebViewTransitionEdge.Bottom, 0.35f); ``` -------------------------------- ### Handle Page Start Event in C# - UniWebView Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md This event handler is triggered when the UniWebView starts loading a URL. It can be invoked by explicit Load calls or navigation within a page. The example demonstrates logging the URL when the page starts loading. ```csharp webView.OnPageStarted += (view, url) => { print("Loading started for url: " + url); }; webView.Load("https://example.com"); // => "Loading started for url: https://example.com/" ``` -------------------------------- ### Loading URLs in UniWebView Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Examples of using the UniWebView Load function to load different types of URLs, including non-existent domains, unknown schemes, and sites with self-signed certificates. These examples illustrate potential error scenarios. ```csharp webView.Load("https://site-not-existing.com/"); // => "Error." webView.Load("unknown://host?param1=value1¶m2=value2"); // => "Error." webView.Load("https://self-signed.badssl.com"); // => "Error." ``` -------------------------------- ### StartAuthenticationFlow Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowGoogle.md Starts the authentication flow using the standard OAuth 2 protocol. ```APIDOC ## StartAuthenticationFlow ### Description Starts the authentication flow with the standard OAuth 2. ### Method void ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (void) This method returns void. #### Response Example None ``` -------------------------------- ### UniWebView - Start Rendering Process Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/render-as-texture.md Initiates the process of rendering UniWebView content into a texture. This method should be called before attempting to create textures. ```APIDOC ## UniWebView - Start Rendering Process ### Description Starts the process of capturing the web view's content for rendering into a texture. This enables the `CreateRenderedTexture()` method. ### Method `StartSnapshotForRendering()` ### Endpoint N/A (This is a C# method within the UniWebView library) ### Parameters None ### Request Example ```csharp public class MyBehaviour : MonoBehaviour { UniWebView webView; void OpenWebView() { webView = gameObject.AddComponent(); webView.Frame = new Rect(0, 0, Screen.width, Screen.height); webView.Load("https://uniwebview.com"); // Start the rendering process. webView.StartSnapshotForRendering(); } } ``` ### Response None (This method initiates an internal process). ### Notes The `Show()` method is not required for rendering to a texture. The process starts even if the web view is not visible. ``` -------------------------------- ### Start Google Authentication Flow in Unity Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/oauth2-google.md Initiates the Google OAuth authentication process by getting the UniWebViewAuthenticationFlowGoogle component and calling its StartAuthenticationFlow method. ```csharp void Start() { var googleFlow = GetComponent(); googleFlow.StartAuthenticationFlow(); } ``` -------------------------------- ### OnPageStarted Event Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Handles the event when the UniWebView starts loading a URL. ```APIDOC ## OnPageStarted Event ### Description Raised when the web view starts loading a url. This event will be invoked for both URL loading with `Load` method or by a link navigating from a page. ### Method Event ### Endpoint N/A (Event) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp webView.OnPageStarted += (view, url) => { print("Loading started for url: " + url); }; webView.Load("https://example.com"); // => "Loading started for url: https://example.com/" ``` ### Response #### Success Response (200) None (Event handler) #### Response Example None ``` -------------------------------- ### Example CSS for Local HTML Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/loading-local-files.md A CSS code snippet demonstrating how to style HTML elements. This example shows a simple rule to change the color of an H1 heading, assuming the CSS file is in the same directory as the HTML file. ```css h1 { color: red; } ``` -------------------------------- ### Render Web View to Texture Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/release-note/README.md Provides functionality to render the web view to a texture, which can then be used within the game world. This feature requires additional setup as detailed in the guide. ```csharp UniWebView.CreateRenderedTexture(webView); // Further implementation steps are required as per the guide. ``` -------------------------------- ### Example HTML Structure for Local File Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/loading-local-files.md An example of an HTML file structure that includes a CSS stylesheet. The CSS file is linked using a relative path, demonstrating how UniWebView handles linked resources from the same directory. ```html

Styled heading

``` -------------------------------- ### Start Continuous Snapshot Rendering Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Begins the process of continuously rendering snapshots of the web view. Optionally accepts a Rect for a specific area and an Action callback. ```C# void StartSnapshotForRendering(Rect? rect = null, Action onStarted = null) ``` -------------------------------- ### UniWebView Initialization and Close Handling Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Example of how to add a UniWebView component to a GameObject and handle the OnShouldClose event. ```APIDOC ## UniWebView Initialization and Close Handling ### Description This snippet demonstrates how to initialize a UniWebView component and configure its behavior when the close event is triggered. ### Method Unity Script (C#) ### Endpoint N/A ### Parameters None ### Request Example ```csharp var webView; void Start() { webView = gameObject.AddComponent(); webView.OnShouldClose += (view) => { webView = null; return true; }; } ``` ### Response No direct response, modifies component behavior. ``` -------------------------------- ### Start GitHub Authentication Flow (C#) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/oauth2-github.md Initiates the GitHub OAuth authentication process by calling StartAuthenticationFlow on the UniWebViewAuthenticationFlowGitHub component. This script should be attached to the same GameObject as the UniWebView component. ```csharp void Start() { var githubFlow = GetComponent(); githubFlow.StartAuthenticationFlow(); } ``` -------------------------------- ### Start Session Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationSession.md Initiates a new session for UniWebView. This is a fundamental step before performing other web-related operations. No specific dependencies are mentioned, and the input is implicitly the current session object. ```csharp session.Start(); ``` -------------------------------- ### Start Authentication Flow Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowCustomize.md Initiates the standard OAuth 2.0 authentication process. This method implements an abstract method from UniWebViewAuthenticationCommonFlow. ```APIDOC ## POST /api/startAuthenticationFlow ### Description Starts the authentication flow with the standard OAuth 2.0. This implements the abstract method in `UniWebViewAuthenticationCommonFlow`. ### Method POST ### Endpoint /api/startAuthenticationFlow ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json // No request body needed for this action. ``` ### Response #### Success Response (200) void - Indicates the flow has started successfully. #### Response Example ```json // No response body returned on success. ``` ``` -------------------------------- ### StartAuthenticationFlow Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationCommonFlow.md This method should be overridden by subclasses to initiate the authentication process, typically by starting a UniWebViewAuthenticationFlow or implementing a custom flow. ```APIDOC ## StartAuthenticationFlow ### Description Subclass should override this method to start the authentication flow. Usually it starts a UniWebViewAuthenticationFlow. But you can also choose whatever you need to do. ### Method abstract void ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### StartRefreshTokenFlow Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowGoogle.md Starts the refresh token flow using the standard OAuth 2 protocol. ```APIDOC ## StartRefreshTokenFlow ### Description Starts the refresh flow with the standard OAuth 2. ### Method void ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **refreshToken** (string) - Required - The refresh token to use for the flow. ### Request Example { "refreshToken": "your_refresh_token_here" } ### Response #### Success Response (void) This method returns void. #### Response Example None ``` -------------------------------- ### Start Refresh Token Flow Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowGoogle.md Initiates the OAuth 2.0 refresh token process using a provided refresh token. ```APIDOC ## void StartRefreshTokenFlow(string refreshToken) ### Description Starts the refresh flow with the standard OAuth 2.0. This implements the abstract method in `UniWebViewAuthenticationCommonFlow`. ### Method POST ### Endpoint N/A (Method call within the SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **refreshToken** (string) - Required - The refresh token to use for the flow. ### Request Example ```csharp // Assuming 'googleFlow' is an instance of the authentication flow class and 'myRefreshToken' is a valid refresh token googleFlow.StartRefreshTokenFlow(myRefreshToken); ``` ### Response #### Success Response (N/A) This method returns void and initiates an external process. #### Response Example N/A ``` -------------------------------- ### Configure and Load a Web Page Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/working-with-code.md This C# code snippet shows how to configure the UniWebView's frame to occupy the full screen and load a specific URL. It also demonstrates how to make the web view visible using the Show() method. This is typically added to the Start() method after the web view is initialized. ```csharp void Start () { //... webView.Frame = new Rect(0, 0, Screen.width, Screen.height); // 1 webView.Load("https://docs.uniwebview.com/game.html"); // 2 webView.Show(); // 3 } ``` -------------------------------- ### Start Authentication Flow - UniWebView Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowCustomize.md Initiates the standard OAuth 2.0 authentication process. This method is part of the UniWebViewAuthenticationFlowCustomize class and is used to begin the authentication sequence defined by the flow's configuration. ```csharp void StartAuthenticationFlow() ``` -------------------------------- ### Basic UniWebView Integration in Unity (C#) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/README.md Demonstrates the fundamental steps to add and display a UniWebView component in a Unity game. It covers adding the component, setting its frame, loading a URL, and showing the web view. ```csharp var webView = gameObject.AddComponent(); webView.Frame = new Rect(0, 0, Screen.width, Screen.height); webView.Load("https://uniwebview.com"); webView.Show(); ``` -------------------------------- ### Configure Gradle Build Settings Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/installation.md This section explains how to modify the `build.gradle` behavior when exporting Unity projects with UniWebView to Android. It covers options related to including the Kotlin runtime and managing dependency duplication. ```text You can use settings in this section to modify the `build.gradle` behavior when exporting the project. By default, UniWebView will add all dependencies it needs. However, if you are using another package manager or some embedded libraries, a duplication might happen when exporting to Android APK file. In this case, you can try to disable a certain option below to let UniWebView use the existing package instead. #### Adds Kotlin Whether Kotlin runtime should be added to the project. UniWebView for Android is written in Kotlin and you need the runtime in your project to run the code. It is on by default. If any other packages of your project is already adding this, you can opt-out this option to skip adding Kotlin to the project. ``` -------------------------------- ### Configure Android Manifest Settings Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/installation.md This section details how to modify the AndroidManifest.xml file for UniWebView. It explains settings for enabling cleartext traffic, granting write external storage permission, and allowing fine location access, which are crucial for certain web functionalities. ```text Settings in this section will be used to adjust the final `AndroidManifest.xml` file of the exported project. #### Uses Cleartext Traffic Set `usesCleartextTraffic` flag to `true` in the "AndroidManifest.xml". From Android 9.0, all plain HTTP traffic is forbidden by default. If you need to display plain HTTP content in the web view, turn it on. #### Write External Storage Add `WRITE_EXTERNAL_STORAGE` permission to the "AndroidManifest.xml". It enables storing an image from the web page to the Download folder on the device. If you need to download and save any files to disk, turn it on. #### Access Fine Location Add `ACCESS_FINE_LOCATION` permission to the "AndroidManifest.xml". It enables the web view to use the location information. To get the location actually, you also need to call [`LocationService.Start`](https://docs.unity3d.com/ScriptReference/LocationService.Start.html) before you open a web page. If you need to use location APIs on the web, turn it on. ``` -------------------------------- ### Enable Multiple Windows Support (C#) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/release-note/README.md Allows opening links with target="_blank" in new web view windows. Requires setting `SetSupportMultipleWindows` to true. ```csharp UniWebView.SetSupportMultipleWindows(true); ``` -------------------------------- ### Get Cookie Ignoring Leading Dot (C#) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/release-note/README.md Fixes an issue where cookies with domain names starting with a dot were not readable using the `GetCookie` method on iOS. This addresses a discrepancy with RFC6265, ensuring the leading dot is ignored for correct cookie matching. ```csharp // No specific code snippet provided, but implies a fix in UniWebView's cookie handling logic. ``` -------------------------------- ### UniWebViewMessage Constructor Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/uniwebviewmessage.md This section details the UniWebViewMessage constructor, used to initialize a new message instance with a raw message string. It explains the 'rawMessage' parameter and provides an example of its usage. ```APIDOC ## UniWebViewMessage Constructor ### Description Initializes a new instance of the UniWebViewMessage struct with a raw message string. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp var message = new UniWebViewMessage("uniwebview://sample_message?key=1&key=2"); ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ### Remarks The `rawMessage` can contain query parameters which will be parsed into the `Args` dictionary. Multiple values for the same key are handled correctly. ``` -------------------------------- ### Get Current Navigation Item (C#) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewBackForwardList.md Gets the current page item displayed in the UniWebView's navigation history. If the history is empty, this will return null. ```csharp UniWebViewBackForwardItem currentItem = webView.CurrentItem; ``` -------------------------------- ### Handle File Download Events (Swift) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/download-files.md Listens for UniWebView's download events in Swift. It logs when a download starts and when it finishes, including success or error codes. Requires UniWebView SDK. ```swift webView.OnFileDownloadStarted += (view, remoteUrl, fileName) => { Debug.Log(string.Format("Download Started. From '{0}', file name '{1}'", remoteUrl, fileName)); }; webView.OnFileDownloadFinished += (view, errorCode, remoteUrl, diskPath) => { if (errorCode == 0) { // Success Debug.Log(string.Format("Download Finished. From '{0}', to '{1}'", remoteUrl, diskPath)); } else { Debug.LogError("Download error: " + errorCode); } }; ``` -------------------------------- ### UniWebView StartAuthenticationFlow Method Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowGitHub.md Initiates the standard OAuth 2.0 authentication process. ```C# public class UniWebViewManager : MonoBehaviour { public void StartAuthenticationFlow() { // Assuming uniWebViewInstance is an instance of UniWebView // uniWebViewInstance.StartAuthenticationFlow(); Debug.Log("Starting authentication flow..."); } } ``` -------------------------------- ### Get User Agent Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Gets the user agent string currently used in the web view. If a customized user agent is not set, the default user agent for the current platform will be returned. ```APIDOC ## GET /api/user-agent ### Description Gets the user agent string currently used in the web view. If a customized user agent is not set, the default user agent for the current platform will be returned. ### Method GET ### Endpoint /api/user-agent ### Response #### Success Response (200) - **userAgent** (string) - The user agent string currently in use. #### Response Example ```json { "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 ..." } ``` ``` -------------------------------- ### Handle File Download Started Event Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Subscribes to the OnFileDownloadStarted event to log download details. This event is triggered when a file download begins, providing the web view instance, the remote URL, and the chosen file name. It's useful for monitoring download progress. ```csharp webView.OnFileDownloadStarted += (view, remoteUrl, fileName) => { print(string.Format("Download Started. From '{0}', file name '{1}'", remoteUrl, fileName)); }; ``` -------------------------------- ### Start Refresh Token Flow Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowCustomize.md Initiates the OAuth 2.0 refresh token flow. This method implements an abstract method from UniWebViewAuthenticationCommonFlow and requires a refresh token string. ```APIDOC ## POST /api/startRefreshTokenFlow ### Description Starts the refresh flow with the standard OAuth 2.0. This implements the abstract method in `UniWebViewAuthenticationCommonFlow`. ### Method POST ### Endpoint /api/startRefreshTokenFlow ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **refreshToken** (string) - Required - The refresh token to use for the authentication. ### Request Example ```json { "refreshToken": "your_refresh_token_here" } ``` ### Response #### Success Response (200) void - Indicates the flow has started successfully. #### Response Example ```json // No response body returned on success. ``` ``` -------------------------------- ### UniWebView - Show Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Makes the UniWebView instance visible. ```APIDOC ## POST /uniwebview/show ### Description Displays the UniWebView instance, making it visible to the user after it has been loaded or configured. ### Method `Show()` ### Endpoint N/A (This is a method call within the UniWebView API, not a REST endpoint) ### Parameters N/A ### Request Example ```csharp // After loading a URL: webView.Load("https://example.com"); webView.Show(); ``` ### Response #### Success Response (200) This method returns `void`. The UniWebView instance becomes visible. #### Response Example N/A ``` -------------------------------- ### UniWebViewAuthenticationCommonFlow Abstract Methods Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationCommonFlow.md Abstract methods that subclasses must implement to define specific authentication and token refresh logic. These include starting the authentication process and handling refresh tokens. ```csharp public abstract void StartAuthenticationFlow(); public abstract void StartRefreshTokenFlow(string refreshToken); ``` -------------------------------- ### Handle Loading Errors with Payload in C# Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md This C# example shows how to use the OnLoadingErrorReceived event, which provides more detailed error information through a UniWebViewNativeResultPayload. It includes a check for the 'Extra' field in the payload to access additional error details, although the example only prints 'Error.' to the console. ```csharp webView.OnLoadingErrorReceived += (view, error, message, payload) => { print("Error."); if (payload.Extra != null && ``` -------------------------------- ### ShowSpinner Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Shows the loading spinner. ```APIDOC ## void ShowSpinner() ### Description Shows the loading spinner. ### Method POST ### Endpoint /showSpinner ### Parameters #### Path Parameters #### Query Parameters ### Request Example { "example": "{}" } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example { "example": "{\"status\": \"success\"}" } ``` -------------------------------- ### UniWebView Show/Hide Transition Parameters Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/transition.md Demonstrates the parameters for UniWebView's Show and Hide methods, including fade and edge transitions. The methods return a boolean indicating if the command was accepted. ```csharp bool Show( bool fade = false, UniWebViewTransitionEdge edge = UniWebViewTransitionEdge.None, float duration = 0.4f, Action completionHandler = null ) bool Hide( bool fade = false, UniWebViewTransitionEdge edge = UniWebViewTransitionEdge.None, float duration = 0.4f, Action completionHandler = null ) ``` -------------------------------- ### GetCookie Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Gets the cookie value under a given url and key. ```APIDOC ## void GetCookie(string url, string key, bool skipEncoding, Action handler) ### Description Gets the cookie value under a given url and key. ### Method GET ### Endpoint /getCookie ### Parameters #### Path Parameters #### Query Parameters - **url** (string) - Required - The URL to get the cookie from. - **key** (string) - Required - The key of the cookie to retrieve. - **skipEncoding** (bool) - Required - Whether to skip URL encoding for the key. - **handler** (Action) - Required - A callback function to receive the cookie value. ### Request Example { "example": "{\"url\": \"https://example.com\", \"key\": \"sessionid\", \"skipEncoding\": false}" } ### Response #### Success Response (200) - **cookieValue** (string) - The value of the requested cookie. #### Response Example { "example": "{\"cookieValue\": \"12345\"}" } ``` -------------------------------- ### SetAllowUserEditFileNameBeforeDownloading Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Controls whether users can edit the filename before a download starts. ```APIDOC ## SetAllowUserEditFileNameBeforeDownloading ### Description Sets whether allowing users to edit the file name before downloading. ### Method (Not specified, likely void return implies a method call) ### Endpoint (Not applicable, this is a C# method signature) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body - **allowed** (bool) - Required - True to allow editing, false otherwise. ### Request Example (Not applicable for this type of method) ### Response #### Success Response (void) (No return value) #### Response Example (Not applicable) ``` -------------------------------- ### UniWebViewSafeBrowsing Methods Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/uniwebviewsafebrowsing.md Documentation for the methods used to create and manage UniWebViewSafeBrowsing instances. ```APIDOC ## UniWebViewSafeBrowsing Methods ### Create #### Description Creates a new `UniWebViewSafeBrowsing` instance with a specified destination URL. The URL cannot be changed after creation. #### Parameters - **url** (string) - Required - The URL to load in the safe browsing component. #### Return Value `UniWebViewSafeBrowsing` - A new instance of the safe browsing component. ### Show #### Description Displays the safe browsing content on top of the current screen. ### Dismiss #### Description Dismisses the safe browsing component programmatically. ### SetToolbarColor #### Description Sets the background color for the toolbar in the safe browsing component. #### Parameters - **color** (Color) - Required - The color to set for the toolbar background. ### SetToolbarItemColor #### Description Sets the color for the controls (icons) within the toolbar of the safe browsing component. #### Parameters - **color** (Color) - Required - The color to set for the toolbar items. ### SetPreferredCustomTabsBrowsers #### Description Sets the preferred browsers for Custom Tabs on Android, in order of preference. #### Parameters - **packages** (string[]) - Required - An array of package names for the preferred browsers. ``` -------------------------------- ### UniWebViewAuthenticationSession Create Method Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationSession.md Creates a new UniWebViewAuthenticationSession with a specified URL and callback scheme. This is the entry point for initiating an authentication flow. ```csharp public static UniWebViewAuthenticationSession Create(string url, string callbackScheme) ``` -------------------------------- ### Create a UniWebView Instance Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Demonstrates how to create a new UniWebView instance by adding the UniWebView component to a GameObject in Unity. This is the fundamental step to initialize a web view within the application. It uses the AddComponent method with generics. ```csharp var webView = gameObject.AddComponent(); ``` -------------------------------- ### UniWebViewLogger LogLevel Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/uniwebviewlogger.md Gets or sets the current logging level for the UniWebViewLogger. ```APIDOC ## GET/PUT /UniWebViewLogger/LogLevel ### Description Gets or sets the current level of this logger. Messages above the current level will not be logged. ### Method GET, PUT ### Endpoint /UniWebViewLogger/LogLevel ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **LogLevel** (UniWebViewLogger.Level) - The desired logging level (Verbose, Debug, Info, Critical, Off). ### Request Example ```json { "LogLevel": "Info" } ``` ### Response #### Success Response (200) - **LogLevel** (UniWebViewLogger.Level) - The current logging level. #### Response Example ```json { "LogLevel": "Info" } ``` ``` -------------------------------- ### Enabling New Window Support for Links Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/support-new-window.md Configure UniWebView to handle links with the `target="_blank"` attribute by enabling multiple window support. ```APIDOC ## POST /api/config/multiple-windows ### Description Enables the behavior for handling new tabs or windows when links with `target="_blank"` are encountered. When enabled, UniWebView will open a new web view instance that overlays the current one, mimicking a new tab. This new instance will be automatically dismissed when closed via JavaScript (e.g., `window.close()`). ### Method POST ### Endpoint /api/config/multiple-windows ### Parameters #### Query Parameters - **supportMultipleWindows** (boolean) - Required - Set to `true` to enable support for multiple windows. - **allowJavaScriptOpening** (boolean) - Required - Set to `false` when only supporting `_blank` links. Set to `true` if you also want to support JavaScript `window.open()` calls. ### Request Example ```csharp webView.SetSupportMultipleWindows(true, false); ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating that multiple window support has been updated. #### Response Example ```json { "message": "Multiple window support configured successfully." } ``` ``` -------------------------------- ### StartAuthenticationFlow Method Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationFlowGitHub.md Initiates the standard OAuth 2.0 authentication process. ```APIDOC ## StartAuthenticationFlow Method ### Description Starts the authentication flow with the standard OAuth 2. ### Method void ### Endpoint N/A (Method call within the UniWebView SDK) ### Parameters None ### Request Example ```csharp UniWebView.Instance.StartAuthenticationFlow(); ``` ### Response N/A (This is a method that initiates a process, not a request/response API) ``` -------------------------------- ### UniWebViewBackForwardList Properties Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewBackForwardList.md Access properties of the UniWebViewBackForwardList to get browsing history details. ```APIDOC ## UniWebViewBackForwardList ### Description Represents the back-forward navigation history list of a UniWebView instance. This class manages the browsing history and provides access to previous and next pages. You do not create an instance of this class directly. Instead, you get an instance of this class to represent the back-forward list of a UniWebView instance by calling the `CopyBackForwardList` method of the `UniWebView` class. The content of this class is read-only and fixed when the instance is created. It does not get updated with the web view's navigation history automatically. If you need the latest navigation history, you should call the method `CopyBackForwardList` again to get a new instance of this class. ### Properties - **AllItems** (List) - Gets all items in the back-forward navigation history list. - **CurrentItem** (UniWebViewBackForwardItem) - Gets the current page item in the navigation history. - **BackItem** (UniWebViewBackForwardItem) - Gets the previous (back) page item in the navigation history. - **ForwardItem** (UniWebViewBackForwardItem) - Gets the next (forward) page item in the navigation history. - **CurrentIndex** (int) - Gets the index of current page in the navigation history. - **Size** (int) - Gets the total number of items in the navigation history. ``` -------------------------------- ### OnPageCommitted Event Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Handles the event when the UniWebView receives a response and starts processing web content. ```APIDOC ## OnPageCommitted Event ### Description Raised when the web view receives response from the server and starts receiving web content. This event will be invoked when the web view has confirmed the response is a web page and has started to receive and process the web content. This happens after `OnPageStarted` but before `OnPageFinished`. This is an ideal place to inject JavaScript code at the earliest possible moment when a page starts loading. Note that JavaScript execution is asynchronous - it may complete after the page finishes loading. For most cases, it is recommended to use `OnPageFinished` event instead, which ensures the page is fully loaded. ### Method Event ### Endpoint N/A (Event) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp webView.OnPageCommitted += (view, url) => { Debug.Log("Web View starts receiving content, URL: " + url); // Inject JavaScript code at early stage ``` ### Response #### Success Response (200) None (Event handler) #### Response Example None ``` -------------------------------- ### Show Web View Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Makes the UniWebView visible on the screen. Supports optional fade animation, transition edge, duration, and a completion handler. ```csharp bool Show(bool fade, UniWebViewTransitionEdge edge, float duration, Action completionHandler); ``` -------------------------------- ### OnPageCommitted Event Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md This event is triggered when the UniWebView receives a response from the server and starts loading the web content. ```APIDOC ## OnPageCommitted Event ### Description Raised when the web view receives response from the server and starts receiving web content. ### Method Event (C# delegate) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Event Signature `void OnPageCommitted(UniWebView webView, string url)` ``` -------------------------------- ### Get Authentication URL (C#) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewAuthenticationSession.md Retrieves the URL of the authentication webpage. This is the URL that was used to create the authentication session. ```csharp string url = UniWebViewAuthenticationSession.Url; // Use the url variable for further processing. ``` -------------------------------- ### Create and Initialize UniWebView Component Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/working-with-code.md This C# code snippet demonstrates how to create a new GameObject, attach a UniWebView component to it, and initialize the web view in a Unity scene. It's the foundational step for using UniWebView programmatically. ```csharp using System.Collections; using System.Collections.Generic; using UnityEngine; public class Controller : MonoBehaviour { UniWebView webView; // Start is called before the first frame update void Start () { // Create a game object to hold UniWebView and add component. var webViewGameObject = new GameObject("UniWebView"); webView = webViewGameObject.AddComponent(); // More to add... } // Update is called once per frame void Update () { } } ``` -------------------------------- ### Get Navigation Item by Index Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/UniWebViewBackForwardList.md Retrieves a specific navigation history item using its index. ```APIDOC ## GET /webview/history/item/{index} ### Description Gets the item at the specified index in the navigation history. ### Method GET ### Endpoint /webview/history/item/{index} ### Parameters #### Path Parameters - **index** (int) - Required - The zero-based index of the navigation history item to retrieve. ### Response #### Success Response (200) - **ItemAtIndex** (UniWebViewBackForwardItem) - The navigation item at the specified index, or null if the index is out of range. #### Response Example ```json { "url": "https://example.com/specific", "title": "Specific Page" } ``` ``` -------------------------------- ### Allow User Choose Action After Downloading - UniWebView Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Determines if users can select how to handle a downloaded file after the download is complete. This enhances user control over downloaded content. ```csharp void SetAllowUserChooseActionAfterDownloading(bool allowed) ``` -------------------------------- ### SetContentInsetAdjustmentBehavior Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Configures how the web view adjusts its content inset. This example shows how to disable inset adjustment. ```APIDOC ## SetContentInsetAdjustmentBehavior ### Description Configures how the web view adjusts its content inset. This is useful for preventing unwanted scroll view adjustments. ### Method `SetContentInsetAdjustmentBehavior` ### Endpoint N/A (This is a client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp var webView = gameObject.AddComponent(); webView.SetContentInsetAdjustmentBehavior(UniWebViewContentInsetAdjustmentBehavior.Never); ``` ### Response #### Success Response (200) N/A (This is a client-side method) #### Response Example N/A ``` -------------------------------- ### UniWebView - Prevent Closing Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/api/README.md Example demonstrating how to prevent the UniWebView from closing by returning false on the OnShouldClose event. ```APIDOC ## UniWebView - Prevent Closing ### Description This code snippet shows how to attach a listener to the `OnShouldClose` event of a UniWebView to prevent it from closing. ### Method Unity Script (C#) ### Endpoint N/A ### Parameters None ### Request Example ```csharp // Make the web view there without being closed webView.OnShouldClose += (view) => { return false; }; ``` ### Response No direct response, modifies component behavior. ``` -------------------------------- ### Enabling New Window Support for JavaScript Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/guide/support-new-window.md Configure UniWebView to handle `window.open()` JavaScript calls by enabling multiple window support and allowing JavaScript opening. ```APIDOC ## POST /api/config/javascript-window-open ### Description Enables the ability for JavaScript code within the web view to open new windows using `window.open()`. This requires both enabling multiple window support and specifically allowing JavaScript to initiate these openings. It's recommended to use this feature cautiously due to potential uncontrolled JavaScript execution. ### Method POST ### Endpoint /api/config/javascript-window-open ### Parameters #### Query Parameters - **allowJavaScriptOpenWindow** (boolean) - Required - Set to `true` to allow UniWebView to receive and handle `window.open()` requests from JavaScript. ### Request Example ```csharp UniWebView.SetAllowJavaScriptOpenWindow(true); webView.SetSupportMultipleWindows(true, true); ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating that JavaScript window opening has been allowed. #### Response Example ```json { "message": "JavaScript window opening is now allowed." } ``` ``` -------------------------------- ### Open Third-Party Apps with URL Schemes (Add) Source: https://github.com/onevcat/uniwebview-docs/blob/master/docs/release-note/README.md Supports opening third-party applications using their registered URL schemes, allowing links to launch other apps. ```csharp Application.OpenURL(customSchemeUrl); ```