Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to store data from Ionic app on the servers?

ANSWERED

Hi,

I have implemented an app for Fitbit Ionic using Fitbit Studio. The app is a simple game but I don't know how I can store data when a user is finished with the game. I'm new to the Fitbit app development. Could some one tell me how I can store the game data? Thanks a lot.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Such files are stored on the watch. If you want them elsewhere, you have to use File Transfer to get them to the companion; then you can use fetch or WebSockets to send them to a server.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
9 REPLIES 9

Have a look at onunload and the File System API.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thanks. Can I get access to the files after my app is published? And if yes, is it possible to read the files via the web API?

Best Answer
0 Votes

Such files are stored on the watch. If you want them elsewhere, you have to use File Transfer to get them to the companion; then you can use fetch or WebSockets to send them to a server.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thank you. I also have another question. What happens if I use file transfer to send a json file from the app to the companion but not send it to a server? Can I still get access to the json file after the app is published by Fitbit?

Best Answer
0 Votes

Publishing the app won't make any difference to your ability to access data. That's the good news.

 

The bad news is that the file on the companion isn't accessible outside of the companion. You can't get at it using a file manager. Even inside the companion, it's really more like a variable in memory than a file in storage.

Peter McLennan
Gondwana Software
Best Answer
0 Votes
Ok, thanks. So in order to store my data that is communicated through
companion, I should store the data to a server right after receiving the
file via companion. Right? I just want to store users game data somewhere
accessible.
Best Answer
0 Votes

Yes, I'm afraid so. If you really want an on-companion-device solution, you could send it to a 'server' running on your companion device; ie, a local program that can intercept the fetch() or WebSocket output from your companion code.

Peter McLennan
Gondwana Software
Best Answer
0 Votes
Thanks again. I also have another question. To send a file to a server, is
it possible to do it via the app itself rather than the companion?
Best Answer
0 Votes

Sorry. 😞

Peter McLennan
Gondwana Software
Best Answer
0 Votes