LocationFilterEvent¶
Delivered to BackgroundGeolocation.onLocationFilter when the SDK rejects data before it reaches your event stream — either a raw tracking sample rejected by the location-filter, or a geofence trigger rejected as spurious or duplicate.
Rejected data is not delivered to BackgroundGeolocation.onLocation / BackgroundGeolocation.onGeofence, so this event is the only way to observe and adapt to it (eg: accuracy degrading while stationary, or auditing which geofence transitions the SDK suppressed and why).
Discriminator: geofence is present only when the rejected datum is a
geofence trigger — it names the fence and the rejected transition, and
location carries the trigger fix that caused it.
BackgroundGeolocation.onLocationFilter((event) => {
if (event.geofence) {
// A geofence trigger was rejected.
const gf = event.geofence;
console.log(`[onLocationFilter] geofence ${gf.action} '${gf.identifier}' rejected: ${gf.reason}`);
console.log("- trigger location:", event.location);
} else {
// A raw tracking sample was rejected.
console.log("[onLocationFilter] rejected:", event.reason, event.accuracy);
if (event.accuracy > event.trackingAccuracyThreshold * 5) {
// GPS has degraded badly — adapt (eg: surface a "poor signal" hint).
}
}
});
Members¶
accuracy¶
Horizontal accuracy (meters) of the rejected sample. Convenience copy of
Location.coords.accuracy for quick threshold comparison.
geofence¶
geofence?:GeofenceFilterInfo;
Present when a geofence ENTER/EXIT trigger was rejected rather than a tracking
sample: identifies the fence, the rejected transition, and why —
LocationFilterEvent.location carries the trigger fix that caused it.
location¶
location:Location;
The rejected location (the raw sample that failed the filter).
The coordinates, accuracy, and timestamp describe the rejected sample itself. Derived fields such as Location.odometer reflect the last accepted fix — a rejected sample does not advance the odometer.
reason¶
reason:LocationFilterReason;
Normalized reason the location was rejected.
trackingAccuracyThreshold¶
The LocationFilter.trackingAccuracyThreshold (meters) in effect when the sample was rejected. Lets you detect "accuracy degraded past my threshold" without separately reading the config.
-1 for geofence-trigger rejections, where it is not applicable.