Android Permissions
EOL Notice
Android Permissions will reach its end-of-life on July 1, 2024, and will no longer receive updates or support. Please see Support Policy for additional information.
The Android Permissions plugin is designed to support Android's new permissions checking mechanism, introduced in Android 8.0 (API level 26). Permissions are requested at time of use rather than at runtime. You can find all permissions here.
Installation
If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.
Next, install the plugin:
- Capacitor
- Cordova
npm install @ionic-enterprise/android-permissions
npx cap sync
ionic cordova plugin add @ionic-enterprise/android-permissions
Index
Classes
Classes
AndroidPermissions
usage:
import { AndroidPermissions } from '@ionic-enterprise/android-permissions/ngx';
constructor(private androidPermissions: AndroidPermissions) { }
...
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.CAMERA).then(
result => console.log('Has permission?',result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.CAMERA)
);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.CAMERA, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
PERMISSION
● PERMISSION: any
checkPermission
▸ checkPermission(permission: string
): Promise
<any
>
Check permission
Parameters:
Name | Type | Description |
---|---|---|
permission | string | The name of the permission |
Returns: Promise
<any
>
Returns a promise
hasPermission
▸ hasPermission(permission: string
): Promise
<any
>
This function still works now, will not support in the future.
Parameters:
Name | Type | Description |
---|---|---|
permission | string | The name of the permission |
Returns: Promise
<any
>
Returns a promise
requestPermission
▸ requestPermission(permission: string
): Promise
<any
>
Request permission
Parameters:
Name | Type | Description |
---|---|---|
permission | string | The name of the permission to request |
Returns: Promise
<any
>
requestPermissions
▸ requestPermissions(permissions: string
[]): Promise
<any
>
Request permissions
Parameters:
Name | Type | Description |
---|---|---|
permissions | string [] | An array with permissions |
Returns: Promise
<any
>
Returns a promise