04-22-2020 09:14
04-22-2020 09:14
Hi,
I am a developer of a cycling platform that already supports a lot of fitness devices.
We need to be able to read the heart rate of a Fitbit wristband device in real time within our Android/iOS App. As it has to be realtime the WebApi is not an option.
Is it possible to read the heart rate in real time using a SDK? (on the smartphone, not on the Fitbit device)
If so, any help to get started would be much appreciated.
04-22-2020 14:09
04-22-2020 14:09
It can be done, but not directly. The watch has to send the data to the Fitbit companion on the phone, which can then send it to a server. Your Android/iOS app would need to be able to act as a server to receive the data.
You'd need to be running a dedicated clockface or app to do this, since only one clockface/app can run at any one time. Communications snafus are also an issue.
04-23-2020 01:20
04-23-2020 01:20
Thank you very much for the answer!
Good to hear that it can be done.
So the flow is like follows?
1. We create a Fitbit app that has to be installed on the Fitbit device with the official Fitbit smartphone app.
2. Our Fitbit App reads the heart rate using the device SDK.
3. Our Fitbit App communicates this with the companion using the Companion SDK
4. The Companion sends the data to our official smartphone app.
If that is correct I still have two questions:
1. Is the Companion a seperate App that has to be installed by the end user or does installing our fitbit app install both simultaneously?
2. Is it possible that our Fitbit app is started on the Fitbit device from our smartphone app? Or does the user need to start our Fitbit app on his fitbit device manually?
04-23-2020 02:06
04-23-2020 02:06
Yep, that's pretty much right. What you're calling a 'Fitbit app' could be a clockface, which is really just the default app that runs when no other apps are running.
Q1: Both the device and companion code are installed simultaneously and automatically; the user only sees one app.
Q2: The user would need to start the app manually, unless the app is a clockface in which case it runs by default.
04-23-2020 02:29
04-23-2020 02:29
Thank you so much.
I think a clockface is not what we should go for as only one clockface can be on the fitbit device.
If everyone would do it like that then you could always user your fitbit only for one purpose.
Or am I missing something?
04-23-2020 02:54
04-23-2020 02:54
You're missing something. 🙂
A recent update introduced a Clocks app, which allows up to five clockfaces to installed on a watch simultaneously. Obviously only one can be set as the default, but swapping between them is easy.
An advantage of a clockface is that it's more likely to be left running. If you're concerned about minimising gaps in your data, this could be safer. Obviously you'd want to give it the ability to actually tell the time (and maybe provide some other useful stats) so wearers aren't inclined to close it too often.
It's easy to convert an app to a clockface and vice versa, so you could defer the decision. (There are a few extra UI restrictions on clockfaces, but that's a detail.)
04-23-2020 03:06
04-23-2020 03:06
Okay, that makes sense.
But if they actually keep the clockface running when they are done with the workout, does it not drain the smartphones battery when still providing real time heart rate data to the companion?
04-23-2020 13:46
04-23-2020 13:46
I probably haven't been paying enough attention. 🙂 You're at least somewhat right: you certainly don't want your clockface/app to be pushing data when it isn't necessary. You could provide it with a UI input to turn data collection on/off but that might be overkill. I didn't realise that your intended utilisation was only for workouts; people often want to collect realtime data pretty much all day (which is fraught with problems).
So yes, an app might make more sense in your case.
Given 'workout', you might also want to consider making your app use the Exercise API. I think that should allow the watch to sample HR more frequently. I suspect that it's also more accurate when HR is elevated.
04-23-2020 14:06
04-23-2020 14:06
Hello,
I am investigating a similar integration so this thread has been very helpful. Thank you!
One part I'm still unsure about: how would my app match my user to the updates coming in to my server from their fitbit via the companion app? Is there a way for the user to authenticate their fitbit from inside of my app? Or some other way to connect my app user account to their fitbit account?
04-23-2020 14:23
04-23-2020 14:23
@aidanwaiteI think that would be up to you. When you use fetch() or WebSocket in companion to get out of the Fitbit 'walled garden', user identification, authentication, session management and privacy are all up to you.
There is oauth2 support available via Fitbit settings, which may be useful in your case.