I have a basic cordova app running on android that loads my main web app in a webview.
When running my web app via cordova it will not download any pdf's over https that are located in the same hosting subscription as my app.
Downloading pdf's over https from other websites work fine - including other hosting subscriptions on the same server.
Downloading pdf's over http work fine no matter where the are hosted.
All other files (including txt files) download ok no matter where they are hosted (either by http or https).
EXAMPLE:
https://mywebsite.com/test.txt (DOWNLOADS OK)
https://mywebsite.com/test.pdf (DOES NOT DOWNLOAD)
http://mywebsite.com/test.pdf (DOWNLOADS OK)
https://anyanotherwebsite.com/test.txt (DOWNLOADS OK)
https://anyanotherwebsite.com/test.pdf (DOWNLOADS OK)
http://anyanotherwebsite.com/test.pdf (DOWNLOADS OK)
MY CODE:
This is my cordova "index.html" file:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="app">
<p>Loading</p>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
This is my cordova "index.js" file:
var app = {
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
onDeviceReady: function() {
var targetUrl = "https://cordova1.mydevelopmentserver.com/";
window.location.replace(targetUrl);
},
};
app.initialize();
This is my cordova "config.xml" file:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.company_name.someid" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>My Awesome App</name>
<author email="dev@cordova.apache.org" href="http://cordova.io">Apache Cordova Team</author>
<content src="index.html" />
<preference name="SplashScreen" value="screen" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-navigation href="https://*.cordova1.mydevelopmentserver.com/*" />
<allow-navigation href="file://*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<preference name="ShowTitle" value="True" />
<preference name="Fullscreen" value="False" />
<plugin name="cordova-plugin-device" spec="^2.0.1" />
<engine name="android" spec="^7.0.0" />
</widget>
Have also trying change the config.xml settings to below but it still does not work:
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="*" />
DOWNLOAD SAMPLE CORDOVA PROJECT: https://drive.google.com/file/d/1Z3TZudstF5WqquW6M-bv-8cit3nUFNcI/view?usp=sharing
The sample cordova project redirects to https://cordova1.mydevelopmentserver.com which contains the following html file which can be used to test the issue. I have also setup https://cordova2.mydevelopmentserver.com exactly the same & the issue still occurs with that domain as well.
<!DOCTYPE html>
<html>
<head>
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;"> -->
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>Hello World</title>
</head>
<body>
<p><a href="https://cordova1.mydevelopmentserver.com/test.txt">https://cordova1.mydevelopmentserver.com/test.txt</a></p>
<p><a href="https://cordova1.mydevelopmentserver.com/test.pdf">https://cordova1.mydevelopmentserver.com/test.pdf</a></p>
<p><a href="http://cordova1.mydevelopmentserver.com/test.pdf">http://cordova1.mydevelopmentserver.com/test.pdf</a></p>
<hr>
<p><a href="https://cordova2.mydevelopmentserver.com/test.txt">https://cordova2.mydevelopmentserver.com/test.txt</a></p>
<p><a href="https://cordova2.mydevelopmentserver.com/test.pdf">https://cordova2.mydevelopmentserver.com/test.pdf</a></p>
<p><a href="http://cordova2.mydevelopmentserver.com/test.pdf">http://cordova2.mydevelopmentserver.com/test.pdf</a></p>
</body>
</html>
OTHER NOTES:
I don't think that it is not an issue with the server as links to a pdf from another website on the same server works ok.
I don't think that it is not an issue with the SSL certificate as other links to hosting subscription with the same SSL work ok.
I'm new to cordova but think it may be an issue with my configuration somewhere but have already ripped out as much of the config as I can.
Cordova version: 7.0
Android version: 7.0
Phone: Samsung S8+
Also tested it on a Samsung S4 running Android 5.0.1 but have the same issue.
Using your example I could reproduce your issue & it looks like it is related to using the WebView. If I use the InAppBrowser I can open PDF's over https fine (no matter where they are).
Hopefully you can at least use the InAppBrowser until a proper solution is found.