12-09-2018 09:50
12-09-2018 09:50
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 Answer12-11-2018 15:32
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.
12-11-2018 15:32
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 Answer12-11-2018 15:32
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.
12-11-2018 15:32
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