cordova-plugin-ionic-webview icon indicating copy to clipboard operation
cordova-plugin-ionic-webview copied to clipboard

When accessed link redirects to app's URL, it doesn't land to app.

Open ChetanGoti opened this issue 3 years ago • 3 comments

Configuration of Cordova App

  • <preference name="Hostname" value="app.example.com" />
  • <allow-navigation href="https://myawesomedomain.com/*" />
  • Android:
    • <preference name="Scheme" value="https" />
    • <allow-navigation href="https://app.example.com/*" />
  • iOS:
    • <preference name="iosScheme" value="app" />
    • <allow-navigation href="app://*"/>

Setup of server end point for https://myawesomedomain.com/abc

  • For Android devices, it sends 302 redirect to https://app.example.com
  • For iOS devices, it sends 302 redirect to app://app.example.com

Repro steps

  1. There is a <a> link on index.html page. Pointing to https://myawesomedomain.com/abc
  2. Android: When tap on the link, it shows error page with error "ERR_NAME_NOT_RESOLVED"
  3. iOS: when tap on the link, it shows Failed to load webpage with error: Redirection to URL with a scheme that is not HTTP(S) error.

Versions

cordova: 10.0.0 cordova-android: 9.0.0 cordova-ios: 6.1.0 cordova-plugin-ionic-webview: 5.0.0

Devices

Android 10 iOS 14.1

Workaround

  • Instead of sending 302 redirect from the above https://myawesomedomain.com/abc end point, if it sends HTML content with a javascript within it to navigate to app URLs, it would work properly.

e.g sample response:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script>
            if(window.navigator.userAgent.includes('iPhone')) {
                location.href = 'app://app.example.com'
            }else{
                location.href = 'https://app.example.com'
            }
        </script>
  </head>
<body></body></html>

ChetanGoti avatar Oct 29 '20 11:10 ChetanGoti

Since this problem still exists, @ChetanGoti did you find a better solution for this, or you can still recommend the above workaround?

gazben avatar May 09 '22 21:05 gazben

While using this ionic-webview plugin, we were using Microsoft App Center's CodePush for pushing updates for the Cordova app. CodePush has reached EOL and is no longer supported since 1 Apr.

So we had to make a migration, and we are now directly embedding the remote URL to cordova entrypoint (since iOS supports SW via AppBound domains). So we are no longer using this plugin.

But while we were using it (pre March), we used this same approach and it served pretty well.

ChetanGoti avatar May 10 '22 06:05 ChetanGoti

Related --> https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/5052 @jcesarmobile

phyr0s avatar Aug 05 '22 07:08 phyr0s