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

What is the correct way to handle settings initialisation

ANSWERED

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

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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

 

View best answer in original post

Best Answer
0 Votes
3 REPLIES 3

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

 

Best Answer
0 Votes

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

Best Answer
0 Votes

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/

Best Answer
0 Votes