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
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);
};
I somehow found a way to work it out on android, in the plugin, inappbrowser.java, on this path: \platforms\android\app\src\main\java\org\apache\cordova\inappbrowser
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")){
try{
Intent 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