UNPKG

1.31 kBJavaScriptView Raw
1// @flow
2
3import { Platform, NativeModules } from 'react-native';
4
5let { ExponentPermissions: Permissions } = NativeModules;
6
7type PermissionType =
8 | 'remoteNotifications'
9 | 'location'
10 | 'camera'
11 | 'contacts'
12 | 'audioRecording'
13 | 'systemBrightness'
14 | 'cameraRoll';
15type PermissionStatus = 'undetermined' | 'granted' | 'denied';
16type PermissionExpires = 'never';
17type PermissionDetailsLocationIOS = {
18 scope: 'whenInUse' | 'always',
19};
20type PermissionDetailsLocationAndroid = {
21 scope: 'fine' | 'coarse' | 'none',
22};
23type PermissionResponse = {
24 status: PermissionStatus,
25 expires: PermissionExpires,
26 ios?: PermissionDetailsLocationIOS,
27 android?: PermissionDetailsLocationAndroid,
28};
29
30export async function getAsync(type: PermissionType): Promise<PermissionResponse> {
31 return Permissions.getAsync(type);
32}
33
34export async function askAsync(type: PermissionType): Promise<PermissionResponse> {
35 return Permissions.askAsync(type);
36}
37
38export const CAMERA = 'camera';
39export const AUDIO_RECORDING = 'audioRecording';
40export const LOCATION = 'location';
41export const REMOTE_NOTIFICATIONS = 'remoteNotifications';
42export const NOTIFICATIONS = REMOTE_NOTIFICATIONS;
43export const CONTACTS = 'contacts';
44export const SYSTEM_BRIGHTNESS = 'systemBrightness';
45export const CAMERA_ROLL = 'cameraRoll';