Cordova inappbrowser does not play media or download .ics calendar file

Cordova inappbrowser does not play media or download .ics calendar file



I am loading an external website which i have no control over, the download buttons or the links that are meant to open somewhere else, e.g .ics or.pdf files do not have any effect or action, like opening it on the app itself with a default application.
this is the code


website


buttons


app


application


onDeviceReady: function() {

var openWindow = function()
var ref = cordova.InAppBrowser.open('https://www.example.com', '_blank', 'location=yes,zoom=no,toolbar=no,enableViewportScale=yes');
ref.addEventListener('exit', function(event) navigator.app.exitApp()
navigator.notification.activityStart("", "loading");
);

var loadStop = function(event)
navigator.notification.activityStop();
ref.removeEventListener('loadstop', loadStop);
;

ref.addEventListener('loadstop', loadStop);
;






Did you think on the permission of external storage, for writing and reading. This could be the problem, else there is no download possible.

– Kai Lück
Sep 11 '18 at 7:51







<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> i have addedd this

– Dalton Kim
Sep 11 '18 at 8:36






Thats a good start, but if you want to open files you need also READ_EXTERNAL_STORAGE

– Kai Lück
Sep 11 '18 at 8:39






I have included both, the error i get when i use a phonegap chrome debugger, when a link with a pdf it shows : Resource interpreted as Document but transferred with MIME type application/pdf: "example.com/upload/documents/presentaties/example.pdf".

– Dalton Kim
Sep 11 '18 at 9:51







The problem is that chrome interpreted this as a document and try to render itself. For that problem is a plugin available: github.com/johnculviner/jquery.fileDownload

– Kai Lück
Sep 11 '18 at 9:58




1 Answer
1



I somehow found a way to work it out on android, in the plugin, inappbrowser.java, on this path: platformsandroidappsrcmainjavaorgapachecordovainappbrowser



on the this method, i added more arguments to get .pdf and .ics files


public boolean shouldOverrideUrlLoading(WebView webView, String url)
if (url.endsWith(".pdf"))
tryIntent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
intent.setPackage("com.android.chrome");
cordova.getActivity().startActivity(intent);
return true;
catch(android.content.ActivityNotFoundException e)
LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());



else if (url.contains("/icsdownload/"))
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);





i also specified which specific package to open with.
i could invite assistance on the ios part



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)