UNPKG

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