Latest 0.6.0
Homepage https://github.com/piemonte/Position
License MIT
Platforms ios 10.0, requires ARC
Authors

Position is a Swift and efficient location positioning library for iOS.

Pod Version Build Status Swift Version GitHub license

Features
🐦 Swift 4
🔭 observer pattern support
“one shot” closure based location requests ( more robust than iOS 9 CoreLocation API
🔒 authorization check and response support
🌌 distance and time-based filtering
🌁 automatic low-power location tracking adjustment when backgrounded setting
🔋 automatic low-power location tracking adjustment from battery monitoring setting

Need a different version of Swift?

  • 4.2 – Target your Podfile to the swift4.2 branch
  • 4.0 – Target your Podfile to the latest release or master

Quick Start

Position is available for installation using the Cocoa dependency manager CocoaPods. Alternatively, you can simply copy the Position source files into your Xcode project.

# CocoaPods
swift_version = "4.0"
pod "Position", "~> 0.4.0"

# Carthage
github "piemonte/Position" ~> 0.4.0

# SwiftPM
let package = Package(
    dependencies: [
        .Package(url: "https://github.com/piemonte/Position", majorVersion: 0)
    ]
)

Usage

The sample project provides an example of how to integrate Position, otherwise you can follow these steps.

Ensure your app’s Info.plist file includes both a location usage description, required device capability “location-services”, and required background mode (if necessary).

See sample project for examples too.

Import the file and setup your component to be a PositionObserver, if you’d like it to be a delegate.

import Position

class ViewController: UIViewController, PositionObserver {
    // ...

Have the component add itself as an observer and configure the appropriate settings.

    override func viewDidLoad() {
        super.viewDidLoad()

        // ...

        Position.shared.addObserver(self)
        Position.shared.distanceFilter = 20

        if Position.shared.locationServicesStatus == .allowedWhenInUse ||
           Position.shared.locationServicesStatus == .allowedAlways {
            Position.shared.performOneShotLocationUpdate(withDesiredAccuracy: 250) { (location, error) -> () in
                print(location, error)
            }
        } else {
            // request permissions based on the type of location support required.
            Position.shared.requestWhenInUseLocationAuthorization()
            // Position.shared.requestAlwaysLocationAuthorization()
        }
    }

Observe delegation, if necessary.

    func position(position: Position, didChangeLocationAuthorizationStatus status: LocationAuthorizationStatus) {
        // location authorization did change, often this may even be triggered on application resume if the user updated settings
    }

Remember when creating location-based apps, respect the privacy of your users and be responsible for how you use their location. This is especially true if your application requires location permission kCLAuthorizationStatusAuthorizedAlways.

Documentation

You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.

Community

Resources

License

Position is available under the MIT license, see the LICENSE file for more information.

Latest podspec

{
    "name": "Position",
    "version": "0.6.0",
    "license": "MIT",
    "summary": "location positioning and tracking for iOS in Swift",
    "homepage": "https://github.com/piemonte/Position",
    "social_media_url": "http://twitter.com/piemonte",
    "authors": {
        "patrick piemonte": "[email protected]"
    },
    "source": {
        "git": "https://github.com/piemonte/Position.git",
        "tag": "0.6.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "Sources/*.swift",
    "requires_arc": true,
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This