UNPKG

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