I am writing a app with using the geolocation interface. I can build and run the app without errors. But after 2-3 minutes run this app my Ionic fails and restart. Anyone have an idea what is wrong in my script?
-------------------------------------------------------------------
Answered! Go to the Best Answer.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
You're probably flooding requests to getPosition() because you aren't waiting for success.
You should probably either switch over to watchPosition(), or stop using setInterval(), and use setTimeout() after location success. Something like:
function getPosition() {
geolocation.getCurrentPosition(locationSuccess, locationError, locationOptions);
console.log("start loop getCurrentPosition");
}
function locationSuccess(position) {
// ...
setTimeout(getPosition, 5000);
}
// Start getting position
getPosition();
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
You're probably flooding requests to getPosition() because you aren't waiting for success.
You should probably either switch over to watchPosition(), or stop using setInterval(), and use setTimeout() after location success. Something like:
function getPosition() {
geolocation.getCurrentPosition(locationSuccess, locationError, locationOptions);
console.log("start loop getCurrentPosition");
}
function locationSuccess(position) {
// ...
setTimeout(getPosition, 5000);
}
// Start getting position
getPosition();
Best Answer