11-18-2021 12:00
11-18-2021 12:00
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
11-18-2021 12:23
11-18-2021 12:23
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).
11-18-2021 12:36
11-18-2021 12:36
We got the heart rate measurements but we want to send it to firebase how is that possible?
11-18-2021 12:44
11-18-2021 12:44
fetch() or websocket from Fitbit companion (I have no idea about the firebase side).
11-18-2021 12:54
11-18-2021 12:54
I got this error maybe you could help me figure out the solution
your help is really appreciated
11-18-2021 12:57
11-18-2021 12:57
You'll need to post the source code. I'm not even sure that you should have a .js file in /settings.
11-19-2021 00:34
11-19-2021 00:34
Do 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
11-19-2021 11:19
11-19-2021 11:19
here'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);*/ });
});
11-19-2021 11:25
11-19-2021 11:25
If 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().
12-04-2021 19:23
12-04-2021 19:23
Hey 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!