07-20-2018 00:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-20-2018 00:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have a created a watchface that uses a companion app to manage its settings.
When the watchface starts after it is installed, it loads the settings file and stores it in an object.
When the companion app detects a change in a settings, it sends it to the watch, which then updates the settings object and executes the appropriate action for that setting.
I am trying to sort out what the sequence is when an app is (re)started.
I used to load the settings file, parse it and process each setting.
The companion app would, at some point kick in and also send me all the settings, which I'd end up also processing.
What is the correct flow?
Empirical evidence shows me that the settings are persisted by the device OS.
Do I need to actually apply the settings from the device settings file each time the app is started.
Or, should I simply read it (so that I have a variable containing the current state) and just process settings that come in from the companion app?
Cheers,
Nick
Answered! Go to the Best Answer.

Accepted Solutions
07-25-2018 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-25-2018 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Settings are only automatically persisted on the phone in settingsStorage.
If you want to persist them on the device, you can do something like this:
https://github.com/Fitbit/sdk-moment/blob/master/app/simple/device-settings.js

07-25-2018 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-25-2018 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Settings are only automatically persisted on the phone in settingsStorage.
If you want to persist them on the device, you can do something like this:
https://github.com/Fitbit/sdk-moment/blob/master/app/simple/device-settings.js

07-26-2018 17:13 - edited 07-26-2018 17:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-26-2018 17:13 - edited 07-26-2018 17:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks Jon.
I already use something similar to save/load settings from the device.
I was unsure whether it was recommended that I should 'apply' those settings every time the app starts.
As it is, I only apply them when the settings file on the device cannot be found (i.e. app is running for very first time).
The file is saved any time a setting is changed (with a small mop-up delay to avoid multiple file I/O calls).
Cheers,
Nick

07-03-2020 09:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-03-2020 09:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I found a way to handle settings without using the companion app. I write the settings to a txt file, save the file, and then when you load the app again, read in the settings from the txt file. Here's a link to read and write files. https://dev.fitbit.com/build/guides/file-system/

