While I am able to create events inside index.js of the companion, I am not able to do so within index.js of the app itself. What am I missing?
index.js:
console.log('Up and running.');
var event = new Event('test');
console.log('Event added.')console output:
[1:45:51 PM] App: App Closed [1:45:51 PM] App: App Started [1:45:51 PM] App: Up and running. (app/index.js:1,1) [1:45:51 PM] App: Unhandled exception: ReferenceError: Event is not defined event at app/index.js:3,1 [1:45:52 PM] Companion: Up and running. (companion/index.js:1,1) [1:45:52 PM] Companion: Event added. (companion/index.js:5,1)
I am using the following versions of the sdk:
Two probably-wrong guesses:
Best Answer
@Gondwana wrote:You may not be importing the right file.
There's no need to import anything inside index.js of the companion to make use of the Event class there, so I'd doubt that.
@Gondwana wrote:The device runs an older version of javascript, so some things that work on the companion don't work on the watch.
I guess so, too. On a different thread I recently read about restricted capabilities of the device regarding date methods like "toLocaleString()". JonFitbit stated the following cause there: "The JavaScript on the device only supports ES5.1, ..." Gonna stick to callbacks then, I'm afraid... /:
Best Answer