12-26-2017 13:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-26-2017 13:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello Ionic-Devs,
I'm trying to import some helper functions in my settings/index.jsx that I want to use also in the companion but I did not get it running:
companion/config.js:
import { settingsStorage } from "settings"; export function setDefaults() {
...
}
settings/index.jsx:
import * as config from "../companion/config.js";
function clear(props)
{
config.setDefaults();
return;
}
...
The compiler error message is:
settings is imported by companion/config.js, but could not be resolved
Did anybody have some hints?
Best regards,
Grizzi

01-09-2018 16:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-09-2018 16:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Have you tried putting config.js inside the /common folder, then referencing it from there? Just a guess.

05-02-2018 10:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-02-2018 10:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Were you able to find any workaround?

07-11-2018 10:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-11-2018 10:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello!
I'm having the same trouble, too.
I encountered this in a project I'm currently working it. To make sure I didn't mess it up by myself, I started a blank project and gave it try. It resulted in the same issue.
In first place I created the blank starter project and put this code in the app/index.js:
import { settingsStorage } from "settings"; settingsStorage.setItem("myKey", "test"); console.log("App code started");
Which results in:
settings is imported by app/index.js, but could not be resolved Build failed.
After that I tried what @JonFitbit suggested and put it into the /common-folder:
app/index.js:
import Test from "../common/test" console.log("App code started"); let test = new Test(); test.retrieveValue();
common/test.js:
import { settingsStorage } from "settings"; export default class Test { constructor() { settingsStorage.setItem("myKey", "test"); } retrieveValue() { console.log(settingsStorage.getItem("myKey")); } }
And the build fails again:
settings is imported by common/test.js, but could not be resolved
What am I doing wrong? I don't get it.
Thanks!

07-13-2018 10:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-13-2018 10:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
and put this code in the app/index.js:
import { settingsStorage } from "settings"; settingsStorage.setItem("myKey", "test"); console.log("App code started");Which results in:
settings is imported by app/index.js, but could not be resolved Build failed.
settingsStorage is part of the companion api, not the device api. It can only be used in the companion/index.js file.
Take a look at the settings guide https://dev.fitbit.com/build/guides/settings/
and the Moment example https://github.com/Fitbit/sdk-moment
07-14-2018 12:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-14-2018 12:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The moment you realize: RTFM is the answer.
Thanks @JonFitbit for your support!

04-11-2020 15:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-11-2020 15:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Suspect I'm completely misunderstanding the architecture of the APIs here, but does this mean it's not possible to access settings in the app?
What if I want to use a setting in my clock.onTick() section?

04-11-2020 16:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-11-2020 16:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You can't DIRECTLY access settings from the watch app, so you're on the right track. You have to use messaging or file transfer to send settings from companion to watch.
Gondwana Software

04-11-2020 17:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-11-2020 17:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks for that.
So I get that I would use messaging in the case where a user changes the settings in the app - to send the new setting to the app.
But I'm trying to format date/time based on user setting so I want to check what's in the settings on each clock.onTick(). Are you saying that I would write those settings to a file to be able to check them at any given point in the app?

04-11-2020 17:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-11-2020 17:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Are you talking about changing settings in the .jsx bit of your app, or other settings in the Fitbit app (eg, 12/24-hour time display formatting)?
You don't need settings to be stored in a file on the watch to be able to access them in onTick(). Variables will do. But you'll probably want to store them in a file on the watch so you can reinitialise the variables if the user restarts your clockface.
I think there's a sample of all this somewhere; it might be here.
Gondwana Software

04-11-2020 17:31
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-11-2020 17:31
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yes, I'm talking about settings set in the .jsx.
So the use case would be:
- Set a setting in app on phone.It's a <Toggle/> selector that will have a boolean value.
- Refer to that setting in onTick() section of app.
Happy to refer to variable in the app - just can't work out where to get the value from.
I've looked at that example app that you posted but couldn't quite see where it does this.

04-11-2020 17:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-11-2020 17:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You've left a lot of steps out of your outline.
- Set a setting in app on phone.It's a <Toggle/> selector that will have a boolean value.
- Detect the .jsx setting change in your companion code.
- Send the setting from companion to clockface (messaging or file transfer).
- Receive setting in clockface (messaging or file transfer).
- Save setting in a variable in clockface.
- Refer to that setting in onTick() section of app.
This ignores the desirability of saving and restoring settings on the clockface to streamline restarts.
Gondwana Software
04-13-2020 07:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-13-2020 07:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks again for your help. Got there in the end.

