fork
Configure Feed
Select the types of activity you want to include in your feed.
mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
fork
Configure Feed
Select the types of activity you want to include in your feed.
1import {useCallback} from 'react'
2import * as Location from 'expo-location'
3
4import {type DeviceLocation} from '#/state/geolocation/types'
5import {getDeviceGeolocation} from '#/state/geolocation/util'
6
7export {PermissionStatus} from 'expo-location'
8
9export function useRequestDeviceLocation(): () => Promise<
10 | {
11 granted: true
12 location: DeviceLocation | undefined
13 }
14 | {
15 granted: false
16 status: {
17 canAskAgain: boolean
18 /**
19 * Enum, use `PermissionStatus` export for comparisons
20 */
21 permissionStatus: Location.PermissionStatus
22 }
23 }
24> {
25 return useCallback(async () => {
26 const status = await Location.requestForegroundPermissionsAsync()
27
28 if (status.granted) {
29 return {
30 granted: true,
31 location: await getDeviceGeolocation(),
32 }
33 } else {
34 return {
35 granted: false,
36 status: {
37 canAskAgain: status.canAskAgain,
38 permissionStatus: status.status,
39 },
40 }
41 }
42 }, [])
43}