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

SDK Sync Events

ANSWERED

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"

 

  1. Is it possible to transfer files from the device to the companion?
  2. 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

 

Ionic & Aria, Blaze (retired), Alta (retired), Surge (retired), Charge HR (retired), One (retired), Classic (retired) | Microsoft Surface | Google Pixel 2XL Android FitBit App
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

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
0 Votes