12-03-2021 22:45
12-03-2021 22:45
Hello, I am relatively new to Fitbit and am building an app for research purposes. I want to develop an app that records GPS coordinates at a fixed interval (10 minutes). I got the app working on the Fitbit simulator but am having trouble on the actual device (Fitbit Sense). Do I need to code the app to send the data somewhere, perhaps using the fetch function? And would I also need to use a companion in any way? Thanks in advance for the help!
12-03-2021 23:17
12-03-2021 23:17
It depends where you want the data to go. You'll probably need to send it from watch to companion, then from there to a server using fetch or WebSocket.
12-04-2021 10:51
12-04-2021 10:51
I would just want the data to be saved in their Fitbit profile to be downloaded via CSV file. Similar to what you can do with the preprogrammed apps.
12-04-2021 11:30
12-04-2021 11:30
Oh, that's different, and would be more difficult or impossible. Your clockface/app would need to send its data from companion to Web API using fetch(), and there's a built-in component to help with the OAuth bit. However, I don't think the Web API accepts much in the way of input. I'm guessing you didn't get that part of it working on the sim.
12-04-2021 11:34
12-04-2021 11:34
Hmm okay. What do you think would be the easiest option then? Just sending it to a companion then to a server as you mentioned before?
12-04-2021 11:35
12-04-2021 11:35
A further thought: if this would satisfy your need, it will be a lot easier!
12-04-2021 11:38
12-04-2021 11:38
Thanks, I'll play around with it and see.
12-04-2021 11:47
12-04-2021 11:47
If you go with the Web API (TCX) approach, you may be able to get a bit more flexibility by writing your own exercise app.
If you can't use the Web API, this and this vaguely show how to get data from watch to server or file. That demo hosts the server on the companion device (phone) only to avoid using HTTPS; if you've got access to a server elsewhere that can do HTTPS, you can use that.
12-04-2021 11:56
12-04-2021 11:56
Does it make any difference that the only variables I'm interested in gathering are GPS coordinates? Would I still have to develop it as an "exercise app" that gathers additional data?
12-04-2021 12:04
12-04-2021 12:04
No. The only advantage to you of building an exercise app would be because the system would automatically put the GPS (and unwanted) data into Fitbit's database, which you could then access using the Web API. That seemed closest to your original desire.
If you can do the server comms independently, then you don't need an exercise app.
Beware that any clockface/app can only collect data (eg, GPS) while it's running on the watch, and clockfaces/apps can't run in the background.
12-04-2021 12:10
12-04-2021 12:10
Oh they cannot run in the background? When I was using the Fitbit simulator there was an option to have apps run in the background. Is this not the case? Also, sorry for all of the questions. I appreciate your help.
12-04-2021 12:17
12-04-2021 12:17
Sorry, I wasn't clear.
A companion component can run in the background, but if the corresponding watch app isn't running, it will only run sporadically and can be woken every five minutes. That may be what you saw.
On-watch clockfaces/apps can't run when some other clockface/app is running, but they do keep running if the display goes off.
The companion can't restart a closed clockface/app on the watch.
Only an on-watch clockface/app can collect data.