Expo Goefence Exit event

  1. SDK Version: 42.01
  2. Platforms(Android/iOS/web/all): Android emulator
  3. Expo-Location: Geofencing

I am developing an app that is attemping to utilize the GeoFencing methods. However, when I start my app, the event Location.GeofencingEventType.Exit is triggered for all my regions that I am observing.

I call the GeoFencing method here:

useEffect(() => {
(async () => {

  await Location.startGeofencingAsync(GEO_LOC, regions)

})();
return async () => {
await Location.stopGeofencingAsync(GEO_LOC)
console.log(‘unmount geofencing’)
}






},)

Here is my task manager:

TaskManager.defineTask(GEO_LOC, ({ data: { eventType, region }, error }) => {
if (error) {
// error handling
return;
}
if (eventType === Location.GeofencingEventType.Enter) {
console.log(“You’ve entered region:”, region.identifier);
socket.emit(‘hooper:increment’, region.identifier)
updateCourt(region.identifier,1)
}
if (eventType === Location.GeofencingEventType.Exit) {
console.log(“You’ve left region:”, region.identifier);
socket.emit(‘hooper:decrement’, region.identifier)
updateCourt(region.identifier,-1)
}

})

So when I start my app, the conditional statement

(eventType === Location.GeofencingEventType.Exit)

is true for each element in the array of regions that is passed into the TaskManger but I am not actually exiting every region.

Is this the intended behavior?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.