|
15 | 15 | */ |
16 | 16 |
|
17 | 17 | import React, {ReactElement, useEffect, useState} from 'react'; |
18 | | -import {Button, Dimensions, Platform, View} from 'react-native'; |
| 18 | +import {Button, Dimensions, Platform, View} from "react-native"; |
19 | 19 |
|
20 | | -import {PERMISSIONS, RESULTS, request} from 'react-native-permissions'; |
| 20 | +import {PERMISSIONS, RESULTS, requestMultiple} from "react-native-permissions"; |
21 | 21 |
|
22 | 22 | import AsyncStorage from '@react-native-async-storage/async-storage'; |
23 | 23 | import { |
@@ -81,17 +81,22 @@ const App: React.FC = (): ReactElement => { |
81 | 81 | }, []); |
82 | 82 |
|
83 | 83 | const checkPermissions = async () => { |
84 | | - const result = await request( |
85 | | - Platform.OS == 'android' |
86 | | - ? PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION |
87 | | - : PERMISSIONS.IOS.LOCATION_ALWAYS, |
88 | | - ); |
| 84 | + const toRequestPermissions = Platform.OS == 'android' ?[ |
| 85 | + PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION, |
| 86 | + PERMISSIONS.ANDROID.READ_MEDIA_IMAGES, |
| 87 | + ] : [ |
| 88 | + PERMISSIONS.IOS.LOCATION_ALWAYS, |
| 89 | + PERMISSIONS.IOS.PHOTO_LIBRARY |
| 90 | + ]; |
| 91 | + |
| 92 | + const permissionStatuses = await requestMultiple(toRequestPermissions); |
| 93 | + const result = permissionStatuses[toRequestPermissions[0]]; |
89 | 94 |
|
90 | 95 | if (result == RESULTS.GRANTED) { |
91 | 96 | setArePermissionsApproved(true); |
92 | 97 | } else { |
93 | 98 | Snackbar.show({ |
94 | | - text: 'Permissions are needed to proceed with the app. Please re-open and accept.', |
| 99 | + text: 'Location permissions are needed to proceed with the app. Please re-open and accept.', |
95 | 100 | duration: Snackbar.LENGTH_SHORT, |
96 | 101 | }); |
97 | 102 | } |
|
0 commit comments