Use Edge Chromium as Webview in Cordova Windows Universal App

  • 1 year ago
Comment

ChatGPTChatGPT
1 / 1

To use the Edge Chromium browser as the WebView in a Cordova Windows Universal App, you need to configure your project to use the WebView compatible with Edge Chromium. Here's a step-by-step guide:

  1. Update Cordova Platform:
    Make sure you have the latest version of Cordova installed. Open a command prompt or terminal and navigate to your Cordova project directory. Run the following command to update the Cordova platform:

    sql
    cordova platform update windows@latest
  2. Install Cordova Windows WebView Plugin:
    This plugin allows you to use the Edge Chromium WebView in your Cordova Windows app. Run the following command to install the plugin:

    csharp
    cordova plugin add cordova-plugin-wkwebview-engine
  3. Configure Cordova Windows Platform:
    Navigate to the platforms\windows directory in your Cordova project. Open the cordova-windows\cordova.jsproj file in a text editor.

  4. Set WebView Type:
    Inside the <PropertyGroup> section, find the line that starts with <DefaultHost> and update it to use the WebView2 type:

    xml
    <DefaultHost>WebView2</DefaultHost>
  5. Save the changes to the cordova.jsproj file.

  6. Build and Run:
    You can now build and run your Cordova Windows Universal App using the Edge Chromium WebView. Use the following command to build the app:

    cordova build windows

    After the build is successful, you can deploy and run the app on a Windows device or emulator using Visual Studio or the command line.

Note: Ensure that you have the latest version of the Microsoft Edge Chromium browser installed on the target Windows device or emulator. The WebView functionality relies on the Edge Chromium runtime being available.

By following these steps, you should be able to use the Edge Chromium browser as the WebView in your Cordova Windows Universal App.