cordova-plugin-ionic-webview
cordova-plugin-ionic-webview copied to clipboard
When accessed link redirects to app's URL, it doesn't land to app.
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
- There is a
<a>
link on index.html page. Pointing tohttps://myawesomedomain.com/abc
- Android: When tap on the link, it shows error page with error "ERR_NAME_NOT_RESOLVED"
- 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>
Since this problem still exists, @ChetanGoti did you find a better solution for this, or you can still recommend the above workaround?
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.
Related --> https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/5052 @jcesarmobile