Hi Fitbit Family,
I want to test the Interface, ActivityHistoryRecord. This is what the reference document says:
"An activity history object represents user activity over some time interval, defined by the interface providing these objects."
This is the url of the document reference: https://dev.fitbit.com/build/reference/device-api/user-activity/#interface-activityhistory
I don't understand, there is no methods associated to this Interface, only properties.
Do you guys have an example that helps me understand how to use this Interface?
Thanks
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.
The docs are a bit of a mess here. The interface defines what's returned from the query() in ActivityHistory. I'll see about getting the example added to that.
Here's one you can use:
https://dev.fitbit.com/blog/2019-10-29-announcing-fitbit-os-sdk-4.0/#activity-history-api
Hi,
I´m working with the example: https://dev.fitbit.com/blog/2019-10-29-announcing-fitbit-os-sdk-4.0/#activity-history-api
The properties: distance, steps and calories, work and give me the data correctly.
But the properties: averageHeartRate and RestingHeartRate always return an undefined. The code is below, it is exactly like the one in the example, but maybe I did something wrong. Is there an error?
Also noticed that there is no property named activeMinutes, which is available for the Activity Interface, but not for ActivityHistoryRecord? Are you guys planning to add this property in the future?
// query all days history step data
const dayRecords = dayHistory.query();
dayRecords.forEach((day, index) => {
console.log(`${day.distance || 0} distance. ${index} day(s) ago.`);
console.log(`${day.steps || 0} steps. ${index} day(s) ago.`);
console.log(`${day.calories || 0} calories. ${index} day(s) ago.`);
console.log(`${day.activeMinutes} activeMinutes. ${index} day(s) ago.`);
console.log(`${day.averageHeartRate} averageHeartRate. ${index} day(s) ago.`);
console.log(`${day.restingHeartRate} restingHeartRate. ${index} day(s) ago.`);
});
Thanks in advance
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.
Is this in the simulator or on a real device?
The activeMinutes property doesn't exist due to the way it's calculated over a 10 minute period of activity.
Best AnswerHi Jon,
It is on a real device. I maybe have something wrong in my code... 😞
I can see why the activeMinutes doesn't make sense if we use the query for minutes:
const minuteRecords = minuteHistory.query({ limit: 5 });But if we use the query for all day:
// query all days history step data const dayRecords = dayHistory.query();
It is a shame that we can´t see the active minutes for the previous days.
Thanks
Best AnswerDid you ever get a response or figure out why the averageHeartRate and restingHeartRate return undefined? I'm also see the day history returning restingHeartRate as undefined on my Iconic.
Best Answer
@JonFitbit wrote:Is this in the simulator or on a real device?
Is the activityHistory available in the simulator with dummy values or are the returned values always zero?
Capitano
Best Answer