I've managed to successfully use the geolocation API in React Native, but when I turn my location off the error callback doesn't seem to work. I've tried providing a timeout option of 5 seconds and I could wait all day and the error would never be called. The weird thing is the error callback will be called if I turn the location back on. It will go to the error callback, then go back to the success.
I've tried using the following code:
navigator.geolocation.getCurrentPosition(
(position) => {
console.log("Got Position");
},
(error) => {
console.log("Got error");
}
);
navigator.geolocation.getCurrentPosition(
(position) => {
console.log("Got Position");
},
(error) => {
console.log("Got error");
},
{timeout: 5000}
);
I've also tried using the "react native android location services dialog box" module, but get the following error and just gave up:
android\app\src\main\java\com\orchardapp\MainApplication.java:7: error: package com.showlocationservicesdialogbox does not exist
import com.showlocationservicesdialogbox.LocationServicesDialogBoxPackage;
^
android\app\src\main\java\com\orchardapp\MainApplication.java:30: error: cannot find symbol
new LocationServicesDialogBoxPackage(),
^
symbol: class LocationServicesDialogBoxPackage
2 errors
I'm building the app on an android 6 device. Just kind of stuck now and not sure what else to use... Has anyone experienced this and got some tips?
Thanks!