Skip to main content

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:

npm install @ionic-enterprise/android-permissions
npx cap sync

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:

NameTypeDescription
permissionstringThe 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:

NameTypeDescription
permissionstringThe name of the permission

Returns: Promise<any> Returns a promise


requestPermission

requestPermission(permission: string): Promise<any>

Request permission

Parameters:

NameTypeDescription
permissionstringThe name of the permission to request

Returns: Promise<any>


requestPermissions

requestPermissions(permissions: string[]): Promise<any>

Request permissions

Parameters:

NameTypeDescription
permissionsstring[]An array with permissions

Returns: Promise<any> Returns a promise