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