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