01-14-2019 11:26
01-14-2019 11:26
Can somebody please post a little example for an onreachgoal event (e.g. daily steps)?
Does the Fitbit Simulator allow user activity manipulation so that I will be able to test this?
Thanks in advance!
Answered! Go to the Best Answer.
Best Answer01-14-2019 13:21
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.
01-14-2019 13:21
I don't think you can test in the simulator, but here's a sample:
import { today, goals } from "user-activity";
goals.addEventListener("reachgoal", (goal, evt) => {
if (today.adjusted.steps >= goal.steps) {
// step goal reached
}
})
Best Answer01-14-2019 13:21
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.
01-14-2019 13:21
I don't think you can test in the simulator, but here's a sample:
import { today, goals } from "user-activity";
goals.addEventListener("reachgoal", (goal, evt) => {
if (today.adjusted.steps >= goal.steps) {
// step goal reached
}
})
Best Answer01-14-2019 14:02
01-14-2019 14:02
Thank you Jon!
Is this event also being fired for active minutes goals, calories goals etc or is it only being fired when the steps goal has been reached?
Best Answer01-14-2019 14:05
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.
01-14-2019 14:05
It's fired for all goals, you just need to determine which have been met.
Best Answer01-15-2019 10:05
01-15-2019 10:05
Thanks, it works perfectly on my Versa!
Best Answer