Search docs/

Android Permissions

v0.11.0

Contents

インストール

Ionic Enterprise Editionのプラグインを利用する場合は、 通常のバージョンでスコープ指定されたプラグインに問題がある可能性があるため、 Ionic Enterprise Cordova CLIを使用していることを確認する必要があります。

npm uninstall -g cordovanpm install -g @ionic-enterprise/cordova

Ionic Enterprise Cordova CLIをインストールしたら、プラグインをインストールできます。

ionic enterprise register --key=YOURPRODUCTKEYionic cordova plugin add @ionic-enterprise/android-permissions

Index

Classes


Classes

AndroidPermissions

AndroidPermissions:

name: Android Permissions

description: This plugin is designed to support Android new permissions checking mechanism.

You can find all permissions here: https://developer.android.com/reference/android/Manifest.permission.html

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]);

Android 26 and above: due to Android 26's changes to permissions handling (permissions are requested at time of use rather than at runtime,) if your app does not include any functions (eg. other Ionic Native plugins) that utilize a particular permission, then requestPermission() and requestPermissions() will resolve immediately with no prompt shown to the user. Thus, you must include a function utilizing the feature you would like to use before requesting permission for it.

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



Other Versions