728x90
- 환경
react-native: 0.61.5
@react-native-community/geolocation: 2.0.2
- 라이브러리
https://github.com/react-native-community/react-native-geolocation
react-native-community/react-native-geolocation
Geolocation APIs for React Native. Contribute to react-native-community/react-native-geolocation development by creating an account on GitHub.
github.com
- 설치
yarn add @react-native-community/geolocation
- 설정
AndroidManifest.xml 에 추가
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Info.plist 에 추가
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string></string>
<key>NSLocationAlwaysUsageDescription</key>
<string></string>
첫 번째 키는 원래 있음
- Usage
Geolocation.getCurrentPosition(async ({coords}) => {
const lat = coords.latitude;
const lon = coords.longitude;
// use lat, lon
});
'Solve Problem > React Native' 카테고리의 다른 글
[React Native] react-redux hooks (0) | 2020.05.01 |
---|---|
[React Native] 날씨 API, 역지오코딩(위도/경도 > 주소), 미세먼지 API (2) | 2020.04.29 |
[React Native] Google Login 구글 로그인 / 소셜 로그인 / 디버그용 릴리즈용 플레이스토어용 SHA-1 (0) | 2020.04.16 |
[노마드코더] 초보자를 위한 리덕스 101 (0) | 2020.03.31 |
[React Native] (2021 v3 업데이트) Kakao login 카카오 로그인 구현하기 (36) | 2020.03.28 |