Installations
npm install suc-cordova-plugin-file-opener2
Developer Guide
Typescript
No
Module System
N/A
Node Version
12.22.1
NPM Version
6.14.12
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (44.02%)
Java (30.34%)
Objective-C (25.64%)
Developer
pwlin
Download Statistics
Total Downloads
400
Last Day
2
Last Week
4
Last Month
10
Last Year
56
GitHub Statistics
318 Stars
264 Commits
587 Forks
29 Watching
3 Branches
34 Contributors
Package Meta Information
Latest Version
3.1.1
Package Id
suc-cordova-plugin-file-opener2@3.1.1
Unpacked Size
43.96 kB
Size
12.39 kB
File Count
16
NPM Version
6.14.12
Node Version
12.22.1
Total Downloads
Cumulative downloads
Total Downloads
400
Last day
0%
2
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
900%
10
Compared to previous month
Last year
-6.7%
56
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No dependencies detected.
A File Opener Plugin for Cordova
This plugin will open a file on your device file system with its default application.
1cordova.plugins.fileOpener2.open( 2 filePath, 3 fileMIMEType, 4 { 5 error : function(){ }, 6 success : function(){ } 7 } 8);
Installation
1$ cordova plugin add cordova-plugin-file-opener2
Optional variables
This plugin requires the AndroidX support library.
1$ cordova plugin add cordova-plugin-file-opener2
Requirements
The following platforms and versions are supported by the latest release:
- Android 4.4+ / iOS 9+ / Windows / Electron
- Cordova CLI 7.0 or higher
Cordova CLI 6.0 is supported by 2.0.19, but there are a number of issues, particularly with Android builds (see 232 203 207). Using the cordova-android-support-gradle-release plugin may help.
fileOpener2.open(filePath, mimeType, options)
Opens a file
Supported Platforms
- Android 4.4+
- iOS 9+
- Windows
- Electron
Quick Examples
Open an APK install dialog:
1cordova.plugins.fileOpener2.open( 2 '/Downloads/gmail.apk', 3 'application/vnd.android.package-archive' 4);
Open a PDF document with the default PDF reader and optional callback object:
1cordova.plugins.fileOpener2.open( 2 '/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Downloads/starwars.pdf 3 'application/pdf', 4 { 5 error : function(e) { 6 console.log('Error status: ' + e.status + ' - Error message: ' + e.message); 7 }, 8 success : function () { 9 console.log('file opened successfully'); 10 } 11 } 12);
Note on Electron: Do not forget to enable Node.js in your app by adding "nodeIntegration": true
to platforms/electron/platform_www/cdv-electron-settings.json
file, See Cordova-Electron documentation.
Market place installation
Install From Market: to install an APK from a market place, such as Google Play or the App Store, you can use an <a>
tag in combination with the market://
protocol:
1<a href="market://details?id=xxxx" target="_system">Install from Google Play</a> 2<a href="itms-apps://itunes.apple.com/app/my-app/idxxxxxxxx?mt=8" target="_system">Install from App Store</a>
or in code:
1window.open("[market:// or itms-apps:// link]","_system");
fileOpener2.showOpenWithDialog(filePath, mimeType, options)
Opens with system modal to open file with an already installed app.
Supported Platforms
- Android 4.4+
- iOS 9+
Quick Example
1cordova.plugins.fileOpener2.showOpenWithDialog(
2 '/Downloads/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Downloads/starwars.pdf
3 'application/pdf',
4 {
5 error : function(e) {
6 console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
7 },
8 success : function () {
9 console.log('file opened successfully');
10 },
11 position : [0, 0]
12 }
13);
position
array of coordinates from top-left device screen, use for iOS dialog positioning.
fileOpener2.uninstall(packageId, callbackContext)
Uninstall a package with its ID.
Note: You need to add <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
to your AndroidManifest.xml
Supported Platforms
- Android 4.4+
Quick Example
1cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', { 2 error : function(e) { 3 console.log('Error status: ' + e.status + ' - Error message: ' + e.message); 4 }, 5 success : function() { 6 console.log('Uninstall intent activity started.'); 7 } 8});
fileOpener2.appIsInstalled(packageId, callbackContext)
Check if an app is already installed.
Supported Platforms
- Android 4.4+
Quick Example
1cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { 2 success : function(res) { 3 if (res.status === 0) { 4 console.log('Adobe Reader is not installed.'); 5 } else { 6 console.log('Adobe Reader is installed.') 7 } 8 } 9});
Android APK installation limitation
The following limitations apply when opening an APK file for installation:
- On Android 8+, your application must have the
ACTION_INSTALL_PACKAGE
permission. You can add it by adding this to your app'sconfig.xml
file:
1<platform name="android"> 2 <config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android"> 3 <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> 4 </config-file> 5</platform>
- Before Android 7, you can only install APKs from the "external" partition. For example, you can install from
cordova.file.externalDataDirectory
, but not fromcordova.file.dataDirectory
. Android 7+ does not have this limitation.
SD card limitation on Android
It is not always possible to open a file from the SD Card using this plugin on Android. This is because the underlying Android library used does not support serving files from secondary external storage devices. Whether or not your the SD card is treated as a secondary external device depends on your particular phone's set up.
Notes
-
For properly opening any file, you must already have a suitable reader for that particular file type installed on your device. Otherwise this will not work.
-
It is reported that in iOS, you might need to remove
<preference name="iosPersistentFileLocation" value="Library" />
from yourconfig.xml
-
If you are wondering what MIME-type should you pass as the second argument to
open
function, here is a list of all known MIME-types
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
Found 2/16 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 16 are checked with a SAST tool
Score
3.2
/10
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More