React-native-webview: Prevent deep linking to third party applications

Created on 28 Apr 2019  路  3Comments  路  Source: react-native-webview/react-native-webview

Is it possible to disable deep linking to other app, for instance if I have amazon installed on my device and open an amazon url with the web view it's pushing me to the amazon app, however I would like to open the amazon website inside the web view ?
Thanks for the help

Stale feature request

Most helpful comment

I was having a similar problem when WebView was trying to open plaidlink://* and I wasn't able to control it. And I noticed that if you add the 3rd party protocol to the originWhitelist, you'd be able to control it inside the onShouldStartLoadWithRequest function:

Something like:

<WebView
  source={{ uri: generateLinkInitializationURL() }}
  onShouldStartLoadWithRequest={request => {
    if (request.url.startsWith('plaidlink')) {
      ...
      return false;
    }

    return true;
  }}
  originWhitelist={['https://*', 'plaidlink://*']}
/>

All 3 comments

I was having a similar problem when WebView was trying to open plaidlink://* and I wasn't able to control it. And I noticed that if you add the 3rd party protocol to the originWhitelist, you'd be able to control it inside the onShouldStartLoadWithRequest function:

Something like:

<WebView
  source={{ uri: generateLinkInitializationURL() }}
  onShouldStartLoadWithRequest={request => {
    if (request.url.startsWith('plaidlink')) {
      ...
      return false;
    }

    return true;
  }}
  originWhitelist={['https://*', 'plaidlink://*']}
/>

The workaround provided by @gaykov worked for me. I used it to disable mailto: links found in a web view.

Hello 馃憢, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rezvalari picture rezvalari  路  3Comments

SimonErich picture SimonErich  路  3Comments

BruceSuperProgramer picture BruceSuperProgramer  路  3Comments

panda0603 picture panda0603  路  3Comments

AdamZaczek picture AdamZaczek  路  3Comments