webyonet / react-native-android-location-services-dialog-box

React Native Android Location Services Dialog Box
MIT License
182 stars 50 forks source link

Location request timed out #65

Closed Revocsid closed 5 years ago

Revocsid commented 5 years ago

Hi, The dialog works fine, location service is correctly opened and my callback is correctly invoked.

The problem is if I call the native method : navigator.geolocation.getCurrentPosition(resolve, reject)

If the location was enabled by the dialog box I have always the same response error {TIMEOUT: 3, POSITION_UNAVAILABLE: 2, PERMISSION_DENIED: 1, message: "Location request timed out", code: 3}

RN : .57.2 react-native-android-location-services-dialog-box: 2.7

webyonet commented 5 years ago

this error is not related to this module. this is related to your device or emulator.

do the following to solve this problem:

enableHighAccuracy: false

navigator.geolocation.getCurrentPosition((position) => {
}, error => console.log(error), 
{ enableHighAccuracy: false, timeout: 20000, maximumAge: 1000 })
 })
msqar commented 5 years ago

@webyonet it worked. But is this recommended? I mean in my case i don't need high accuracy but... would this bring other problems?

webyonet commented 5 years ago

@msqar in fact this is a geolocation bug on some devices. this use case will vary completely according to your need