Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save susanna2222/6076df195c02124aa20b632eced10fde to your computer and use it in GitHub Desktop.
Save susanna2222/6076df195c02124aa20b632eced10fde to your computer and use it in GitHub Desktop.
func setupLocationManager(){
if CLLocationManager.authorizationStatus() != CLAuthorizationStatus.authorizedAlways{
// Request to get alwayls location authorization
locationManager.requestAlwaysAuthorization()
}
// set delegate for location manager
locationManager.delegate = self
// setup attributes of location manager
locationManager.distanceFilter = 1
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.showsBackgroundLocationIndicator = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment