I am having some issues in communicating with the companion. It seems to start only once in a while.
My starting code is the same as of a new project from studio with file transfer.
Companion starts only once in a while. Also timestamp seems to be completely off. Please see below.
Is there a basic launch code to insert in the app/index.js so that it goes straight to start companion code?
My code in the app:
import document from "document";
import { inbox } from "file-transfer";
import fs from "fs";
// console.log("App Started");
let statusText = document.getElementById("status");
statusText.innerText = "Waiting...";
// Event occurs when new file(s) are received
inbox.onnewfile = () => {
console.log("New file!");
let fileName;
do {
// If there is a file, move it from staging into the application folder
fileName = inbox.nextFile();
if (fileName) {
console.log(`Received File: <${fileName}>`);
let data = fs.readFileSync(fileName, "json");
statusText.innerText = `Received: ${data}`;
}
} while (fileName);
};
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.