Skip to content

Integration Guide

Eric Internicola edited this page Jan 6, 2019 · 3 revisions

Prerequisites

  • See the Getting Started guide for the prerequisites
  • It's assumed you've already installed GeoTrackKit
  • It's assumed you've already updated your Info.plist to allow access to Location Services

Integrating GeoTrackKit

Overview

  1. Import GeoTrackKit
  2. Register with NotificationCenter for the Notification.Name.GeoTrackKit.didUpdateLocations notification
  3. When you catch that event, get the current track with GeoTrackManager.shared.track
  4. Optionally, compute stats about that track: GeoTrackAnalyzer(track: GeoTrackManager.shared.track).calculate()

Code Examples:

Importing GeoTrackKit:

import GeoTrackKit

Registering with Notification Center:

NotificationCenter.default.addObserver(self, 
            selector: #selector(locationDidUpdate(_:)), 
            name: Notification.Name.GeoTrackKit.didUpdateLocations, 
            object: nil)

Implementing the Location Update function:

@objc
func locationDidUpdate(_ notification: NSNotification) {
    let analyzer = GeoTrackAnalyzer(track: GeoTrackManager.shared.track).calculate()
    // now update the UI from this
}
Clone this wiki locally