02-03-2019 04:10
02-03-2019 04:10
Hello guys,
i never developed frontend/apps or similar stuff. So first of all, i tought myself javascript/css/.gui/Fitbit Api just enough to get a decent app running properly in Fitbit Simulator. When i tried to flash the app to my Fitbit via developer bridge, the app starts running on my main screen and i don't seem to find a way to kill it.
What i am asking for in detail:
1. How to kill the app and restore my fitbit without factory reset?
2. How to flash an app that gets it's own app 'logo' and can be started from app menu, just like all the other apps.
3. How to implement to following:
if( Application == Active):
--> Return to homescreen, run in background when left button is pressed
--> Return to homescreen, run in Backgground when top right button is pressed
--> Reset application, run in foreground when lower right button is pressed
Thanks a lot in advance 🙂
Answered! Go to the Best Answer.
02-03-2019 11:48
02-03-2019 11:48
Could it be that you developed a clockface instead of an app? The behaviour you described would seem to suggest that.
The change is quite easy; it's a setting in Studio or package.json.
To remove a sideloaded (not 'flashed') clockface, I think you can do it from the companion's Fitbit app: open 'Developer', select it from the list of sideloaded things, and 'Delete'/'Remove'. If that doesn't work, try to select another clockface from the Fitbit app.
02-03-2019 11:48
02-03-2019 11:48
Could it be that you developed a clockface instead of an app? The behaviour you described would seem to suggest that.
The change is quite easy; it's a setting in Studio or package.json.
To remove a sideloaded (not 'flashed') clockface, I think you can do it from the companion's Fitbit app: open 'Developer', select it from the list of sideloaded things, and 'Delete'/'Remove'. If that doesn't work, try to select another clockface from the Fitbit app.
02-03-2019 12:35
02-03-2019 12:35
Thanks a lot, worked like a charm 🙂
Yet i have one more question. If i start the app, everythings works alright. If i leave the app and reopen, the application just restarts. I would like to keep the app in Ram and keep my timers alive, even if i exit to desktop. I already checked the box "run in background".
Any idea?
And one more low prior question, do you know how to set a picture as app picture?
02-03-2019 12:44
02-03-2019 12:44
Your app/clockface can't stay running if the user opens another app. If you need to be able to resume it from its previous state, you'll need to save that state when it closes (or before) (eg, in onunload), and reload the state (if it exists) when the app restarts.
'Run in background' applies to the companion only, I think.
The 'app picture' is an 'icon'.
02-03-2019 13:22
02-03-2019 13:22
Does safe/restore mean save to filesystem .csv and reload? Or is there any inbuild functionality 'if(action == leaveApp) snapshot;'?
02-03-2019 13:30
02-03-2019 13:30
Alas, there's no built-in shortcut. You're on the right track with filesystem .csv (or .cbor, which is faster and takes less memory and file space).
I think there's a package on github that you could splice into your app to do it, or see how it's done. I just do it the hard way; ie, writing my own code. 🙂
02-03-2019 13:35
02-03-2019 13:35
sounds good, i will try to implement .cbor restore routine and upload my final app version to github. Yet i can't figure out how where 'icon' is and how to add it. Is it a menu option or do i have to implement via .gui?
02-03-2019 13:37
02-03-2019 13:37
btw are there any big open source projects using javascript to mess around with? I would like to see how other people handle .gui, .css. For me, starting with fitbitos feels very hart.
02-03-2019 13:40
02-03-2019 13:40
Search for 'icon' here. There's more somewhere, but that should suffice.
02-03-2019 13:43
02-03-2019 13:43
Fitbit's official github respository is here. Many third-party developers have also made stuff available on github. There may be a partial list of such things on the Fitbit site.
02-03-2019 14:59
02-03-2019 14:59
I just tried to implement cbor but got a little bit stuck for the last 30 minutes. I tried to check if there is a file to read already. If there is a file, read it. If data is obsolete, replace it. If there i no data, create data.
Unfortunately i always get the error 'Unhandled Error: failed to pre-parse snapshot' when i attempt to run it. Did i use cbor wrong?
function isSnapshotObsolete(snapshotDate) {
var currDate = new getDay();
if (currDate > safeDate) {
return true;
}
return false;
}
day = new getday() try{ let snapshot = fs.readFileSync("snapshot.txt", "cbor"); if (isSnapshotObsolete(snapshot.time)){ let snapshot = { "day": day, "shortDayFinishHr": shortDayFinishHr, "shortDayFinishMin": shortDayFinishMin, "normalDayFinishHr": normalDayFinishHr, "normalDayFinishMin": normalDayFinishMin, "longDayFinishHr": longDayFinishHr, "longDayFinishHr": longDayFinishHr, }; fs.writeFileSync("snapshot.txt", snapshot, "cbor"); } } catch(err){ let snapshot = { "day": day, "shortDayFinishHr": shortDayFinishHr, "shortDayFinishMin": shortDayFinishMin, "normalDayFinishHr": normalDayFinishHr, "normalDayFinishMin": normalDayFinishMin, "longDayFinishHr": longDayFinishHr, "longDayFinishHr": longDayFinishHr, }; fs.writeFileSync("snapshot.txt", snapshot, "cbor"); }
02-03-2019 18:01
02-03-2019 18:01
Short answer: dunno. Perhaps delete the , in
longDayFinishHr,
(both place). That's just a wild guess.