mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: Permissions API
This commit is contained in:
21
packages/core/permissions/index.d.ts
vendored
Normal file
21
packages/core/permissions/index.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export * from './common';
|
||||
export type PermissionsType = 'location' | 'camera' | 'microphone' | 'photo' | 'contacts' | 'event' | 'reminder' | 'bluetooth' | 'bluetoothConnect' | 'bluetoothScan' | 'notification' | 'backgroundRefresh' | 'speechRecognition' | 'mediaLocation' | 'mediaLibrary' | 'motion' | 'storage' | 'callPhone' | 'readSms' | 'receiveSms';
|
||||
export interface PermissionRationale {
|
||||
title: string;
|
||||
message: string;
|
||||
buttonPositive?: string;
|
||||
buttonNegative?: string;
|
||||
buttonNeutral?: string;
|
||||
}
|
||||
export type PermissionCheckOptions = string | { type: string };
|
||||
export type PermissionRequestOptions = string | { type: string; rationale?: PermissionRationale };
|
||||
export type PermissionResult<T> = T extends any[] ? { [k: string]: Status } : [Status, boolean];
|
||||
|
||||
export class Permissions {
|
||||
static canOpenSettings(): Promise<boolean>;
|
||||
static openSettings(): Promise<boolean>;
|
||||
static getTypes(): Permissions[];
|
||||
static check<T = Permissions>(permission: T, options?: CheckOptions): Promise<PermissionResult<T>>;
|
||||
static request<T = Permissions | Permissions[] | string[]>(permission: T, options?: RequestOptions): Promise<PermissionResult<T>>;
|
||||
static checkMultiple<T = Permissions[]>(permissions: T): Promise<PermissionResult<T>>;
|
||||
}
|
||||
Reference in New Issue
Block a user