Swiftpack.co - Package - piemonte/Position

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

Build Status Pod Version Swift Version GitHub license

| | Features | |:---------:|:---------------------------------------------------------------| | ☄ | “one shot” request-based architecture | | 🛰 | location tracking support | | 📊 | Automatically manage tracking resources based on requests | | 🔒 | authorization check and response support | | 🌌 | distance and time-based filtering | | 📍 | vCard location sharing | | 🌁 | automatic low-power location tracking adjustment when backgrounded setting | | 🔋 | automatic low-power location tracking adjustment from battery monitoring setting | | 🔭 | multiple component observer support | | 🐦 | Swift 5 |

Need a different version of Swift?

  • 5.0 - Target your Podfile to the latest release or master
  • 4.2 - Target your Podfile to the swift4.2 branch

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
pod "Position", "~> 0.7.0"

# Carthage
github "piemonte/Position" ~> 0.7.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.

To share a location using a vCard, simply call the vCard function on any location object instance.

   let fileURL = location.vCard()

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.

Github

link
Stars: 48
Help us keep the lights on

Dependencies

Used By

Total: 1