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

launchReasons.locationChanged not working?

ANSWERED

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.

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

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