From 249ac804282d91f025e58a927d68fefbd96df81a Mon Sep 17 00:00:00 2001 From: Bartosz Dotryw Date: Fri, 21 Dec 2018 04:31:20 +0100 Subject: [PATCH] [expo] Update Permission typings to match SDK31 docs --- types/expo/expo-tests.tsx | 5 ++--- types/expo/index.d.ts | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index aa69df28ad..8d0b1568be 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -695,13 +695,12 @@ Permissions.CAMERA === 'camera'; Permissions.CAMERA_ROLL === 'cameraRoll'; Permissions.AUDIO_RECORDING === 'audioRecording'; Permissions.CONTACTS === 'contacts'; -Permissions.NOTIFICATIONS === 'remoteNotifications'; -Permissions.REMOTE_NOTIFICATIONS === 'remoteNotifications'; +Permissions.NOTIFICATIONS === 'notifications'; Permissions.SYSTEM_BRIGHTNESS === 'systemBrightness'; Permissions.USER_FACING_NOTIFICATIONS === 'userFacingNotifications'; Permissions.REMINDERS === 'reminders'; async () => { - const result = await Permissions.askAsync(Permissions.CAMERA); + const result = await Permissions.askAsync(Permissions.CAMERA, Permissions.CONTACTS); result.status === 'granted'; result.status === 'denied'; diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index 5d86a67150..e89bcba394 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -1905,7 +1905,7 @@ export namespace Pedometer { export namespace Permissions { type PermissionType = 'audioRecording' | 'calendar' | 'cameraRoll' | 'camera' | 'contacts' | 'location' | 'reminders' | - 'remoteNotifications' | 'systemBrightness' | 'userFacingNotifications'; + 'notifications' | 'systemBrightness' | 'userFacingNotifications'; type PermissionStatus = 'undetermined' | 'granted' | 'denied'; type PermissionExpires = 'never'; @@ -1917,17 +1917,23 @@ export namespace Permissions { scope: 'fine' | 'coarse' | 'none'; } - interface PermissionResponse { + interface SinglePermissionResponse { status: PermissionStatus; expires: PermissionExpires; ios?: PermissionDetailsLocationIOS; android?: PermissionDetailsLocationAndroid; } - function getAsync(type: PermissionType): Promise; - function askAsync(type: PermissionType): Promise; + interface PermissionResponse { + status: PermissionStatus; + expires: PermissionExpires; + permissions: { + [key in PermissionType]: SinglePermissionResponse + }; + } - type RemoteNotificationPermission = 'remoteNotifications'; + function getAsync(...permissionTypes: PermissionType[]): Promise; + function askAsync(...permissionTypes: PermissionType[]): Promise; const AUDIO_RECORDING: 'audioRecording'; const CALENDAR: 'calendar'; @@ -1935,9 +1941,8 @@ export namespace Permissions { const CAMERA: 'camera'; const CONTACTS: 'contacts'; const LOCATION: 'location'; - const NOTIFICATIONS: RemoteNotificationPermission; - const REMINDERS = 'reminders'; - const REMOTE_NOTIFICATIONS: RemoteNotificationPermission; + const NOTIFICATIONS: 'notifications'; + const REMINDERS: 'reminders'; const SYSTEM_BRIGHTNESS: 'systemBrightness'; const USER_FACING_NOTIFICATIONS = 'userFacingNotifications'; }