Skip to content

MotionChangeEvent

export interface MotionChangeEvent {

Motion-state change delivered to BackgroundGeolocation.onMotionChange.

The SDK fires this event each time it transitions between the moving and stationary states. A location is always recorded at the moment of transition.

BackgroundGeolocation.onMotionChange((event) => {
  if (event.isMoving) {
    console.log("[onMotionChange] Device is moving:", event.location);
  } else {
    console.log("[onMotionChange] Device is stationary:", event.location);
  }
});

Members

isMoving

isMoving: boolean;

true when the SDK has transitioned to the moving state; false when it has transitioned to the stationary state.

location

location:Location;

Location recorded at the moment the motion-state transition was detected.