Created
January 17, 2017 05:22
-
-
Save dilhan2013/1b5d788a2f330ac984c4d3cbfff6536d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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