Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dilhan2013/1b5d788a2f330ac984c4d3cbfff6536d to your computer and use it in GitHub Desktop.
Save dilhan2013/1b5d788a2f330ac984c4d3cbfff6536d to your computer and use it in GitHub Desktop.
// this code sniplet assumes that you have installed cordova in app browser plugin
// ios and android
function openFile(url) {
window.resolveLocalFileSystemURL(url, function (fileEntry) {
var ios = cordova.file.cacheDirectory;
var ext = cordova.file.externalCacheDirectory;
var dir = (ext) ? ext : ios;
window.resolveLocalFileSystemURL(dir, function (dirEntry) {
fileEntry.copyTo(dirEntry, url.split('/').pop(), function (newFileEntry) {
window.open(newFileEntry.toURL(), '_system');
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment