Skip to content

Commit 2f4cef3

Browse files
fix: update README
Add more relevant information
1 parent 0b01d05 commit 2f4cef3

File tree

1 file changed

+101
-52
lines changed

1 file changed

+101
-52
lines changed

README.md

Lines changed: 101 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,25 @@
11
# OSGeolocationLib
22

3-
The `OSGeolocationLib-iOS` is a libary built using `Swift` that enables its callers to access a device's GPS capabilities, such as latitude, longitude and altitude. Its key features are:
4-
- Get the device's current location.
5-
- Set up watches for location updates.
6-
- Clear previously set watches.
7-
8-
## Index
9-
10-
- [Motivation](#motivation)
11-
- [Usage](#usage)
12-
- [Features](#features)
13-
- [`OSGLOCServicesChecker`](#osglocserviceschecker)
14-
- [Check if Location Services are Enabled](#check-if-location-services-are-enabled)
15-
- [`OSGLOCAuthorisationHandler`](#osglocauthorisationhandler)
16-
- [Location Services' Authorisation Status Property](#location-services-authorisation-status-property)
17-
- [Location Services' Authorisation Status Publisher](#location-services-authorisation-status-publisher)
18-
- [Request User's Permission to Use Location Services](#request-users-permission-to-use-location-services)
19-
- [`OSGLOCLocationHandler`](#osgloclocationhandler)
20-
- [Current Location Property](#current-location-property)
21-
- [Current Location Publisher](#current-location-publisher)
22-
- [Update the Location Manager's Configuration](#update-the-location-managers-configuration)
23-
- [`OSGLOCSingleLocationHandler`](#osglocsinglelocationhandler)
24-
- [Request Device's Current Location](#request-devices-current-location)
25-
- [`OSGLOCMonitorLocationHandler`](#osglocmonitorlocationhandler)
26-
- [Start Monitoring the Device's Position](#start-monitoring-the-devices-position)
27-
- [Stop Monitoring the Device's Position](#stop-monitoring-the-devices-position)
28-
29-
## Motivation
30-
31-
This library is to be used by the Geolocation Plugin for OutSystems' [Cordova](https://google.com) and [Capacitor](https://google.com) Plugins.
32-
33-
## Usage
34-
35-
The library is available on CocoaPods as `OSGeolocationLib`. The following is an example of how to insert it into a Cordova plugin (through the `plugin.xml` file).
3+
A Swift library for iOS that provides simple, reliable access to device GPS capabilities. Get location data, monitor position changes, and manage location services with a clean, modern API.
364

37-
```xml
38-
<podspec>
39-
<config>
40-
<source url="https://cdn.cocoapods.org/"/>
41-
</config>
42-
<pods use-frameworks="true">
43-
...
44-
<pod name="OSGeolocationLib" spec="${version to use}" />
45-
...
46-
</pods>
47-
</podspec>
48-
```
5+
[![Version](https://img.shields.io/cocoapods/v/OSGeolocationLib.svg)](https://cocoapods.org/pods/OSGeolocationLib)
6+
[![Platform](https://img.shields.io/cocoapods/p/OSGeolocationLib.svg)](https://cocoapods.org/pods/OSGeolocationLib)
7+
[![License](https://img.shields.io/github/license/ionic-team/OSGeolocationLib.svg)](LICENSE)
8+
9+
## Requirements
10+
11+
- iOS 14.0+
12+
- Swift 5.0+
13+
- Xcode 15.0+
14+
15+
## Installation
4916

50-
It can also be included as a dependency on other podspecs.
17+
### CocoaPods
18+
19+
`OSGeolocationLib` is available through [CocoaPods](https://cocoapods.org). Add this to your Podfile:
5120

5221
```ruby
53-
Pod::Spec.new do |s|
54-
...
55-
s.dependency 'OSGeolocationLib', '${version to use}'
56-
...
57-
end
22+
pod 'OSGeolocationLib', '~> 1.0.0' # Use the latest 1.0.x version
5823
```
5924

6025
## Features
@@ -200,4 +165,88 @@ The method returns immediately. By calling it, it triggers an update to `current
200165
func stopMonitoringLocation()
201166
```
202167

203-
The method should be called whenever you no longer need to received location-related events.
168+
The method should be called whenever you no longer need to received location-related events.
169+
170+
## Quick Start
171+
172+
This library is currently used by the Geolocation Plugin for OutSystems' [Cordova](https://google.com) and [Capacitor](https://google.com) Plugins. Please check the library usage there for real use-case scenarios.
173+
174+
## Error Handling
175+
176+
The library uses `OSGLOCLocationError` for error handling regarding location position updates. Possible errors include:
177+
178+
```swift
179+
enum OSGLOCLocationError: Error {
180+
case locationUnavailable
181+
case other(_ error: Error)
182+
}
183+
```
184+
185+
## Location Data Format
186+
187+
Location updates are delivered as `OSGLOCPositionModel` objects:
188+
189+
```json
190+
{
191+
"latitude": 37.7749,
192+
"longitude": -122.4194,
193+
"altitude": 0.0,
194+
"horizontalAccuracy": 5.0,
195+
"verticalAccuracy": 10.0,
196+
"course": 180.0,
197+
"speed": 0.0,
198+
"timestamp": 1641034800000
199+
}
200+
```
201+
202+
## Battery Impact Considerations
203+
204+
- High accuracy mode (`enableHighAccuracy: true`) uses GPS and significantly impacts battery life
205+
- Consider using a larger `minimumUpdateDistanceInMeters` for battery optimization
206+
- Call `stopMonitoringLocation()` when updates are no longer needed
207+
208+
## Background Location
209+
210+
To enable background location updates:
211+
212+
1. Add required background modes to `Info.plist`:
213+
```xml
214+
UIBackgroundModes
215+
Location updates
216+
```
217+
218+
2. Request "always" authorization:
219+
220+
```swift
221+
locationService.requestAuthorisation(withType: .always)
222+
```
223+
224+
## Troubleshooting
225+
226+
Common issues and solutions:
227+
228+
1. Location updates not received
229+
- Check authorization status
230+
- Verify location services are enabled
231+
- Ensure proper `Info.plist` permissions
232+
233+
2. Poor accuracy
234+
- Enable high accuracy mode
235+
- Ensure clear sky view
236+
- Wait for better GPS signal
237+
238+
## Contributing
239+
240+
1. Fork the repository
241+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
242+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
243+
4. Push to the branch (`git push origin feature/amazing-feature`)
244+
5. Open a Pull Request
245+
246+
## License
247+
248+
`OSGeolocationLib` is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
249+
250+
## Support
251+
252+
- Report issues on our [Issue Tracker](https://github.com/ionic-team/OSGeolocationLib-iOS/issues)

0 commit comments

Comments
 (0)