docs(): added docs for installing apk / ipa file from marketplace. closes #57

This commit is contained in:
shnist 2018-12-11 17:11:39 +00:00
parent ab3da281c6
commit 4d70f315df

View File

@ -16,11 +16,14 @@ Requirements
Installation Installation
------------- -------------
```shell
$ cordova plugin add cordova-plugin-file-opener2 $ cordova plugin add cordova-plugin-file-opener2
$ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_VERSION={required version} $ cordova plugin add cordova-plugin-file-opener2 --variable ANDROID_SUPPORT_VERSION={required version}
```
Usage Usage
------ ------
```javascript
cordova.plugins.fileOpener2.open( cordova.plugins.fileOpener2.open(
filePath, filePath,
fileMIMEType, fileMIMEType,
@ -29,18 +32,33 @@ Usage
success : function(){ } success : function(){ }
} }
); );
```
Examples Examples
-------- --------
Open an APK install dialog: Open an APK install dialog:
```javascript
cordova.plugins.fileOpener2.open( cordova.plugins.fileOpener2.open(
'/sdcard/Download/gmail.apk', '/sdcard/Download/gmail.apk',
'application/vnd.android.package-archive' 'application/vnd.android.package-archive'
); );
```
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:
```html
<a href="market://details?id=xxxx" target="_system">Install from Google Play</a>
<a href="itms-apps://itunes.apple.com/app/my-app/idxxxxxxxx?mt=8" target="_system">Install from App Store</a>
```
or in code:
```javascript
window.open("[market:// or itms-apps:// link]","_system");
```
Open a PDF document with the default PDF reader and optional callback object: Open a PDF document with the default PDF reader and optional callback object:
```javascript
cordova.plugins.fileOpener2.open( cordova.plugins.fileOpener2.open(
'/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf
'application/pdf', 'application/pdf',
@ -53,9 +71,9 @@ Open a PDF document with the default PDF reader and optional callback object:
} }
} }
); );
```
Open a system modal to open PDF document with one of the already installed app and optional callback object: Open a system modal to open PDF document with one of the already installed app and optional callback object:
```javascript
cordova.plugins.fileOpener2.showOpenWithDialog( cordova.plugins.fileOpener2.showOpenWithDialog(
'/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf '/sdcard/Download/starwars.pdf', // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf
'application/pdf', 'application/pdf',
@ -68,6 +86,7 @@ Open a system modal to open PDF document with one of the already installed app a
} }
} }
); );
```
Notes Notes
------ ------
@ -78,11 +97,12 @@ Notes
- 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](http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co) - 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](http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co)
Android APK installation limitation Android APK installation limitation
--- ---
The following limitations apply when opening an APK file for installation: 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's `config.xml` file: - On Android 8+, your application must have the `ACTION_INSTALL_PACKAGE` permission. You can add it by adding this to your app's `config.xml` file:
``` ```xml
<platform name="android"> <platform name="android">
<config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android"> <config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
@ -99,7 +119,7 @@ The following functions are available in Android platform:
`.uninstall(packageId, callbackContext)` `.uninstall(packageId, callbackContext)`
--- ---
Uninstall a package with its id. Uninstall a package with its id.
```javascript
cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', { cordova.plugins.fileOpener2.uninstall('com.zynga.FarmVille2CountryEscape', {
error : function(e) { error : function(e) {
console.log('Error status: ' + e.status + ' - Error message: ' + e.message); console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
@ -108,11 +128,11 @@ Uninstall a package with its id.
console.log('Uninstall intent activity started.'); console.log('Uninstall intent activity started.');
} }
}); });
```
`.appIsInstalled(packageId, callbackContext)` `.appIsInstalled(packageId, callbackContext)`
--- ---
Check if an app is already installed. Check if an app is already installed.
```javascript
cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', { cordova.plugins.fileOpener2.appIsInstalled('com.adobe.reader', {
success : function(res) { success : function(res) {
if (res.status === 0) { if (res.status === 0) {
@ -122,7 +142,7 @@ Check if an app is already installed.
} }
} }
}); });
```
--- ---
LICENSE LICENSE