03-18-2018 05:44
03-18-2018 05:44
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.
03-19-2018 22:49 - edited 03-19-2018 22:49
03-19-2018 22:49 - edited 03-19-2018 22:49
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.
03-18-2018 13:12
03-18-2018 13:12
I'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.
03-19-2018 22:49 - edited 03-19-2018 22:49
03-19-2018 22:49 - edited 03-19-2018 22:49
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.