Greetings,
I'm new to fitbit developer studio and wondering how could i access real time heart rate sensored data through an api as i need to display it on my project application for educational purpose.
Any help would be appreciated.
Regards,
sarah
It can be done, but it's difficult. You can get real-time heart rate from the device API. You need to pass that from the watch to the companion (phone), and from there to a server (which could reside on your phone). There are several threads about the process in this forum.
It's easier if you don't need real-time data (just use the web API).
We got the heart rate measurements but we want to send it to firebase how is that possible?
fetch() or websocket from Fitbit companion (I have no idea about the firebase side).
Best AnswerI got this error maybe you could help me figure out the solution
your help is really appreciated
You'll need to post the source code. I'm not even sure that you should have a .js file in /settings.
Best AnswerDo you have a step by step explanation on how to develop the device properly and send data to companion and use the fetch command.
i feel that i'm a bit confused.
regards
Best Answerhere's the companion code I can send the data to the companion app but the problem is that i tried the fetch() and it is not working here is the companion code:
import * as messaging from "messaging";
const data = { "heartRate": "evt.data"};
messaging.peerSocket.addEventListener("open", (evt) => {});
messaging.peerSocket.addEventListener("message", (evt) => {
fetch('<API-URL>', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => {
/*console.log(response);*/})
.catch(error => {
/*console.log(error);*/ });
});
Best AnswerIf you search this forum, you'll find several discussions on this topic.
There are several examples of watch-to-companion communications included in this list. The Accelerometer Fetcher and Android Fitbit Fetcher could be adapted, but for real-time data you won't want to buffer readings on the watch or companion, and should probably use WebSockets rather than fetch().
Best AnswerHey I'm trying to do the exact same thing, and I got the exact same error, although it appears in my app and companion side. As far as I know, this particular error occurs as soon as you try to put in the firebase integration. Like, just importing firebase causes it. No clue how to continue... Have you resolved it?
Thanks in advance!
Best Answer