1 |
|
2 |
|
3 | import { Platform, 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 | | 'cameraRoll';
|
15 | type PermissionStatus = 'undetermined' | 'granted' | 'denied';
|
16 | type PermissionExpires = 'never';
|
17 | type PermissionDetailsLocationIOS = {
|
18 | scope: 'whenInUse' | 'always',
|
19 | };
|
20 | type PermissionDetailsLocationAndroid = {
|
21 | scope: 'fine' | 'coarse' | 'none',
|
22 | };
|
23 | type PermissionResponse = {
|
24 | status: PermissionStatus,
|
25 | expires: PermissionExpires,
|
26 | ios?: PermissionDetailsLocationIOS,
|
27 | android?: PermissionDetailsLocationAndroid,
|
28 | };
|
29 |
|
30 | export async function getAsync(type: PermissionType): Promise<PermissionResponse> {
|
31 | return Permissions.getAsync(type);
|
32 | }
|
33 |
|
34 | export async function askAsync(type: PermissionType): Promise<PermissionResponse> {
|
35 | return Permissions.askAsync(type);
|
36 | }
|
37 |
|
38 | export const CAMERA = 'camera';
|
39 | export const AUDIO_RECORDING = 'audioRecording';
|
40 | export const LOCATION = 'location';
|
41 | export const REMOTE_NOTIFICATIONS = 'remoteNotifications';
|
42 | export const NOTIFICATIONS = REMOTE_NOTIFICATIONS;
|
43 | export const CONTACTS = 'contacts';
|
44 | export const SYSTEM_BRIGHTNESS = 'systemBrightness';
|
45 | export const CAMERA_ROLL = 'cameraRoll';
|