reactjs - GeofencingEventType.Exit is triggered for all geofences that are located on map - Stack Overflow

admin2025-04-18  2

try {
    await Location.startGeofencingAsync(
      TASK_MANAGER_NAMES.GEOFENCE_TASK,
      geoZones,
    );
  } catch (error) {
    console.error('Error starting geofencing:', error);
  }

after i triggered that function all geofences that located outside my location is triggered by

if (eventType === GeofencingEventType.Enter) {
      await scheduleNotificationAsync({
        content: {
          title: 'Geofence Alert',
          body: `You entered the region: ${address[0].name}`,
        },
        trigger: null,
      });
    } else if (eventType === GeofencingEventType.Exit) {
      await scheduleNotificationAsync({
        content: {
          title: 'Geofence Alert',
          body: `You exited the region: ${address[0].name}`,
        },
        trigger: null,
      });
    }

For example, I have seven geofences, and I stay inside one of them. I receive seven push notifications: one about entering the location and six about exiting the location

I expected to recieve notification only when i entered or exited geofences

转载请注明原文地址:http://www.anycun.com/QandA/1744958668a90038.html