Last active
May 24, 2024 15:22
-
-
Save christocracy/65bd674283dde9207e0fbe7ea96e5bd6 to your computer and use it in GitHub Desktop.
Background Geolocation Geofencing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Listen for geofence events. | |
BackgroundGeolocation.onGeofence((params) => { | |
console.log('- Geofence event: ', params.identifier); | |
}); | |
// Add a geofence | |
await BackgroundGeolocation.addGeofence({ | |
identifier: 'HOME', | |
radius: 200, | |
latitude: 45.51818958022214, | |
longitude: -73.61409989192487, | |
notifyOnEntry: true, | |
notifyOnExit: true | |
}); | |
// Remove a geofence | |
await BackgroundGeolocation.removeGeofence("HOME"); | |
// Fetch geofences | |
BackgroundGeolocation.getGeofences((geofences) => { | |
console.log('- Geofences: ', geofences); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment