cordova-plugin-file-opener2/README.md

57 lines
1.9 KiB
Markdown
Raw Normal View History

2014-09-26 02:27:28 +08:00
A File Opener Plugin for Cordova (The Original Version)
2014-02-10 19:42:31 +08:00
==========================
This plugin will open a file on your device file system with its default application.
Requirements
-------------
2014-09-26 02:27:28 +08:00
- Android 4 or higher / iOS 6 or higher
2014-02-10 19:42:31 +08:00
- Cordova 3.0 or higher
Installation
-------------
cordova plugin add [url-of-the-git-repo]
2014-09-26 02:27:28 +08:00
PhoneGap Build
---------------
This Plugin is also available in PhoneGap Build Repository. Go to [https://build.phonegap.com/](https://build.phonegap.com/)
And search for `io.github.pwlin.cordova.plugins.fileopener2`
(There are a couple of other forks out there which are mostly out of date. Make sure to download the one with the exact same id as mentioned above)
2014-02-10 19:42:31 +08:00
Usage
------
Open an APK install dialog:
<script>
cordova.plugins.fileOpener2.open(
'/sdcard/Download/gmail.apk',
'application/vnd.android.package-archive'
);
</script>
Open a PDF document with the default PDF reader and optional callback object:
<script>
cordova.plugins.fileOpener2.open(
'/sdcard/Download/starwars.pdf',
'application/pdf',
{
error : function(errorObj) {
alert('Error status: ' + errorObj.status + ' - Error message: ' + errorObj.message);
},
success : function () {
alert('file opened successfully');
}
}
);
</script>
2014-05-18 20:11:51 +08:00
Notes
------
- For properly opening a PDF file, you must already have a PDF reader (Acrobat Reader, Foxit Mobile PDF, etc. ) installed on your mobile device. Otherwise this will not work
- [It is reported](https://github.com/pwlin/cordova-plugin-file-opener2/issues/2#issuecomment-41295793) that in iOS, you might need to remove `<preference name="iosPersistentFileLocation" value="Library" />` from your `config.xml`
2014-02-10 19:42:31 +08:00