12-15-2017 16:26
12-15-2017 16:26
I'm using the below sample from the Companion Guide to be woken up when the companion/device detects a significant location change (editing variable to position due to forum filters):
// Import the Companion module
import { me } from "companion"
if (me.launchReasons.locationChanged) {
// The companion was started due to a significant change in physical location
console.log("Significant location change!")
var position = me.launchReasons.locationChanged.position
console.log("Latitude: " + position.coords.latitude,
"Longitude: " + position.coords.longitude)
}I have the necessary monitor flag set and while the companion is indeed invoked during a location change (as I'll see the console output of "Significant location change!"), the position variable is undefined. Any suggestions?
Side note: anyone have luck using a fake-gps emulator to trigger an event like this from the companion? I can get the fake-gps to work fine for all my apps but not in the fitbit app.
Answered! Go to the Best Answer.
Best Answer12-16-2017 12:37
12-16-2017 12:37
Figured it out. The locationChanged *is* the position, there is no property called 'position'. Docs should be updated or code fixed, but there's also onsignificantlocationchange that gets called when already running, and this event does have a property called position of the event parameter.
Best Answer12-16-2017 12:37
12-16-2017 12:37
Figured it out. The locationChanged *is* the position, there is no property called 'position'. Docs should be updated or code fixed, but there's also onsignificantlocationchange that gets called when already running, and this event does have a property called position of the event parameter.
Best Answer