pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.3k stars 1.63k forks source link

unknown_url_scheme #763

Closed Trend74X closed 3 years ago

Trend74X commented 3 years ago

Description

I want to redirect to dialpad with given number when I click on telephone icon/ somewhere. My webview code is coded in angular and it redirects into dialpad when it runs in chrome, but shows error while running in inappwebview. I dont think its already implemented in inappwebview .

Issue it shows is net::ERR_UNKNOWN_URL_SCHEME

pichillilorenzo commented 3 years ago

That's the expected behavior. You need to implement it by yourself. People may get confused thinking that a WebView is a Browser (such as Chrome, Firefox, Safari, etc.). It is not.

WebView: https://www.pcmag.com/encyclopedia/term/webview Web Browser: https://www.pcmag.com/encyclopedia/term/web-browser

To achieve what you need, you need to use the shouldOverrideUrlLoading event (to be able to listen this event, you need to enable the useShouldOverrideUrlLoading webview option). Also, you can use the url_launcher plugin to open the dialpad. Here is an example:

shouldOverrideUrlLoading: (controller, navigationAction) async {
  var uri = navigationAction.request.url!;

  if (uri.scheme == 'tel') {
    if (await canLaunch(url)) {
      // Launch the App
      await launch(
        url,
      );
      // and cancel the request
      return NavigationActionPolicy.CANCEL;
    }
  }

  return NavigationActionPolicy.ALLOW;
},
github-actions[bot] commented 1 month ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.