01-14-2019 11:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-14-2019 11:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.

Accepted Solutions
01-14-2019 13:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-14-2019 13:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
}
})

01-14-2019 13:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-14-2019 13:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
}
})

01-14-2019 14:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-14-2019 14:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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?

01-14-2019 14:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-14-2019 14:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It's fired for all goals, you just need to determine which have been met.

01-15-2019 10:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-15-2019 10:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks, it works perfectly on my Versa!

