03-18-2018 05:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-18-2018 05:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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"
- Is it possible to transfer files from the device to the companion?
- If not, whats the best way for my app to know if can talk to the companion and process its cache file when communication is next available? - without the user having to reopen the app
Answered! Go to the Best Answer.

Accepted Solutions
03-19-2018 22:49 - edited 03-19-2018 22:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-19-2018 22:49 - edited 03-19-2018 22:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-18-2018 13:12
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.
Gondwana Software

03-19-2018 22:49 - edited 03-19-2018 22:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-19-2018 22:49 - edited 03-19-2018 22:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.

