Created
June 6, 2014 05:57
-
-
Save jhurliman/45bcdfbe2240e72c8bc7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import CoreLocation | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate { | |
var window: UIWindow? | |
let locationManager: CLLocationManager = CLLocationManager() | |
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { | |
locationManager.delegate = self | |
return true | |
} | |
deinit { | |
locationManager.delegate = nil | |
} | |
func applicationDidBecomeActive(application: UIApplication) { | |
locationManager.requestAlwaysAuthorization() | |
locationManager.startMonitoringVisits() | |
} | |
func locationManager(manager: CLLocationManager!, didVisit visit: CLVisit!) { | |
NSLog("didVisit \(visit)") | |
} | |
func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) { | |
NSLog("[ERROR] \(error)") | |
} | |
func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) { | |
var str: String | |
switch (status) { | |
case .NotDetermined: str = "NotDetermined" | |
case .Restricted: str = "Restricted" | |
case .Denied: str = "Denied" | |
case .Authorized: str = "Authorized" | |
case .AuthorizedWhenInUse: str = "AuthorizedWhenInUse" | |
} | |
NSLog("CLAuthorizationStatus: \(str)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment