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

send int var from settings to app (very beginner question)

ANSWERED

hi their,

sorry for asking , i m very new to fitbit SDK and i have a very few skills in programing.

i have almost finished my first app, now i only need to parse a few ints from the settings on the phone to my app...

i'm messing around for hours now... and all examples i can found are color relative and i'm missing the very basic int transmission. 

so here is what i have : 

in settings index.jsx

i need the user to give me an int:

  <TextInput
          label="Heure"
          placeholder="HH"
          settingsKey="Heure"
        />

then in companion i keep the default script witch i assume is prefect.

then in app/index.js:

import document from "document";
import * as messaging from "messaging";
var monHeure = 0;

// Message is received
messaging.peerSocket.onmessage = evt => {
  // i want my var to be filled with the TextInput value as so:
  // monHeure= the value of "heure"??
  }

It looks so simple that i really apologise for the question...but beginning in programing every thing is such a pain.... If you could show me the right methode &syntax i would really be thankfull!

Merci!!!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions
// Message is received
messaging.peerSocket.onmessage = evt => {
console.log(`App received: ${JSON.stringify(evt)}`);

if (evt.data.key === "Heure" && evt.data.newValue)//////////////////////////////////
{
monHeure = (JSON.parse(evt.data.newValue)).name;
console.log(`New date: ${monHeure}`);
}

View best answer in original post

Best Answer
0 Votes
1 REPLY 1
// Message is received
messaging.peerSocket.onmessage = evt => {
console.log(`App received: ${JSON.stringify(evt)}`);

if (evt.data.key === "Heure" && evt.data.newValue)//////////////////////////////////
{
monHeure = (JSON.parse(evt.data.newValue)).name;
console.log(`New date: ${monHeure}`);
}
Best Answer
0 Votes