Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skedgo/geomonitor
iOS library for background monitoring of a user's movement
https://github.com/skedgo/geomonitor
Last synced: about 23 hours ago
JSON representation
iOS library for background monitoring of a user's movement
- Host: GitHub
- URL: https://github.com/skedgo/geomonitor
- Owner: skedgo
- License: mit
- Created: 2022-05-23T06:56:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-31T07:14:27.000Z (over 1 year ago)
- Last Synced: 2024-10-30T17:20:49.577Z (16 days ago)
- Language: Swift
- Homepage:
- Size: 34.2 KB
- Stars: 2
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# GeoMonitor
A battery-efficient and privacy-friendly mini framework for monitoring the user's
location, triggering callbacks when the user starts moving and monitoring
whether the user approaches specified regions.Relies on a mixture of techniques, such as:
- Region-monitoring for detecting when the user leaves their current location
- Region-monitoring for detecting when the user approaches pre-defined locations
- Visit-monitoring for detecting when the user has arrived somewhere## Setup
1. Configure your *Target*:
- Go to *Signing & Capabilities*, *Background Modes* and make sure *Location updates* is ticket.
- Go to *Info*, and make sure you have usage descriptions for "Privacy - Location Always", "Privacy - Location Always and When in Use", and "Privacy - Location When In Use" set.## Usage
*GeoMonitor requires iOS 14+*
```swift
self.monitor = GeoMonitor {
// Fetch the latest regions; also called when entering one.
// Make sure `region.identifier` is stable.
let regions = await ...
return circles = regions.map { CLCircularRegion(...) }
} onEvent: { event, currentLocation in
switch event {
case .departed(visit):
// Called when a previously-visited location was left
case .entered(region):
// Called when entering a defined region.
let notification = MyNotification(for: region)
notification.fire()
case .arrived(visit):
// Called when a visit was registered
}
}
monitor.enableVisitMonitoring = true
monitor.start()
```## Considerations
Regular iOS restrictions apply, such as:
> [...] When Background App Refresh is disabled, either for your app or for all apps, the user must explicitly launch your app to resume the delivery of all location-related events.