FrontEnd/React Native
[react native] 위치정보 가져오기 (expo)
무무둥
2023. 2. 25. 17:51
https://docs.expo.dev/versions/latest/sdk/location
Location
Expo is an open-source platform for making universal native apps for Android, iOS, and the web with JavaScript and React.
docs.expo.dev
#expo-location 설치
> npx expo install expo-location
Method
1. 디바이스 권한요청 (필수)
- requestBackgroundPermissionsAsync() : 백그라운드 권한요청
- requestForegroundPermissionsAsync() : 포그라운드 권한요청
- getLastKnownPositionAsync(options) : 유저의 마지막 위치 get
- getCurrentPositionAsync(options) : 현재 위치 get
- watchPositionAsync(options, callback) : 위치 관찰(이동 추적)
- geocodeAsync(address, options) : 주소를 위도, 경도로 변환
- reverseGeocodeAsync(location, options) : 위도,경도를 입력하면 주소를 반환
- startGeofencingAsync(taskName, regions) : 유저가 특정 지역을 벗어났을 때 알림