웃던날
Daily Star
웃던날
전체 방문자
오늘
어제
  • 분류 전체보기 (14)
    • Daily (0)
    • Job (12)
      • React (4)
      • PHP (1)
      • RN (6)
    • Portfolio (2)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • reactnative
  • JS
  • axios
  • 도넛프로그레스
  • style-component props
  • 물리back
  • Redux toolkit
  • styleComponent
  • rn
  • 상태확인
  • FlashList
  • RecyclerListView
  • @propery
  • 스타일컴포넌트
  • 프론트앤드
  • zustand
  • react native
  • 시간비교
  • 앱개발
  • CelarText
  • getTime
  • 리액트 네이티브
  • fe
  • react
  • scrollview
  • 상태관리
  • FlatList
  • frontend
  • 리액트
  • 프론트엔드

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
웃던날

Daily Star

[React,React Native, JavaScript] GeoLocation error code 3
Job/React

[React,React Native, JavaScript] GeoLocation error code 3

2022. 9. 2. 11:30

1. 문제발생

React Native 프로젝트 진행중 GPS문제가 자꾸 말썽이었다.

한페이지는 무조건 GPS가 작동해야만 뷰가 가능한 페이지였다.

그런데 GPS를 끄고 진입했을시 GeoLocation으로 error 처리를 하고 home으로 되돌렸다.

문제는 여기서 발생했다. Home에서 GPS를 다시켠후 재 진입하더라도 GPS가 꺼져있다는 오류가 발생했었다.

정확하게는 ERROR CODE 3이 출력되었다.

2.문제분석

https://stackoverflow.com/questions/41129088/react-native-android-location-request-timed-out

 

React Native Android location request timed out

In IOS there isn't a problem while looking for gps coords. It works fine. On Android side its not stable as IOS. This problem both in real device and emulator. Sometimes it can find location, but

stackoverflow.com

해당 사이트에서 알아봤는데, 타임아웃 요청시간을 설정해줘야한다고 한다.

const geoLocation = () => { // 경위도 가져오기
        Geolocation.getCurrentPosition(position => {
           get location...
        },
        error => {
           (error...)
        },
        { enableHighAccuracy: false, timeout: 5000, maximumAge: 10000 })
    }

여기서 내가 이해하기론 enableHighAccuracy는 GPS를 사용할지 말지 설정하는 것이다. 

false면 WIFI나 모바일 데이터를 사용해 위치정보를 불러오겠다는 것이고,

true면 GPS자체에서 위치정보를 불러오겠다고 선언 하는것이다.

3. 문제해결

회사 자산이다보니까 결과물을 올리기가 힘들다 ㅜㅜ...

아무튼 정상적으로 작동하지만, GPS정보를 불러오는데 시간이 좀 걸리는 것 같다.

GPS페이지에 진입시 로딩을 켜주고 redux나 asyncStorage에 lat값과 lng 값을 저장해줄때까지 로딩을 돌려버렸다.

잘작동한다...!!

'Job > React' 카테고리의 다른 글

[React , HTML] 겹쳐진 항목클릭시 자식요소 클릭 이벤트 발생시키기  (0) 2023.07.07
[React] 도넛 프로그레스 animation 적용 (style-component, transition)  (0) 2023.06.23
[JavaScript, React Native, React] {"_U": 0, "_V": 0, "_W": null, "_X": null} 출력  (1) 2022.09.01
    'Job/React' 카테고리의 다른 글
    • [React , HTML] 겹쳐진 항목클릭시 자식요소 클릭 이벤트 발생시키기
    • [React] 도넛 프로그레스 animation 적용 (style-component, transition)
    • [JavaScript, React Native, React] {"_U": 0, "_V": 0, "_W": null, "_X": null} 출력
    웃던날
    웃던날

    티스토리툴바