I'm working on a Ionic app to track users moods and store the values in a web service.
The problem I'm finding is the Messaging API isn't always available. So far I've got around this by storing events in a cache file and sending them to the commanion the next time its available, but this only works the next time a user inputs their mood and if the messaging API is available then.
I've looked at using the wakeInterval to wake the companion up, but when it wake the messaging channel isnt available. Another option I've been looking at is the file-transfer API, but all the examples I can find involve sending files from the companion to the device.
I've tried this code in my companion:
import {inbox} from "file-transfer";
inbox.onnewfile = (evt) => {
let originalName = inbox.nextFile("tempfile");
console.log("Received", originalName);
}but I get the error "TypeError: Cannot set property 'onnewfile' of undefined"
Answered! Go to the Best Answer.
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.
Messaging should be a lot more reliable in 2.0 (it's available now), but you should always cater for connection problems.
File transfer doesn't currently support Device > Companion, but hopefully it will in the future.
Best AnswerI'm wondering whether you could flip your logic around: instead of trying to push data from watch to companion, try to pull it to companion from watch. Use the settings page as a controller: put a 'download' button or something on it which, when triggered, fires up companion code to communicate with the watch. This makes it more likely that both companion and watch will be active at the same time.
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.
Messaging should be a lot more reliable in 2.0 (it's available now), but you should always cater for connection problems.
File transfer doesn't currently support Device > Companion, but hopefully it will in the future.
Best Answer