Advertisement
iHunterX

Untitled

Sep 11th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
  2. if status == .notDetermined || status == .denied || status == .authorizedWhenInUse {
  3. // present an alert indicating location authorization required
  4. // and offer to take the user to Settings for the app via
  5. // UIApplication -openUrl: and UIApplicationOpenSettingsURLString
  6. DispatchQueue.main.async(execute: {
  7. let alert = UIAlertController(title: "Error!", message: "GPS access is restricted. In order to use tracking, please enable GPS in the Settigs app under Privacy, Location Services.", preferredStyle: UIAlertControllerStyle.alert)
  8. alert.addAction(UIAlertAction(title: "Go to Settings now", style: UIAlertActionStyle.default, handler: { (alert: UIAlertAction!) in
  9. print("")
  10. UIApplication.shared.openURL(NSURL(string:UIApplicationOpenSettingsURLString)! as URL)
  11. }))
  12. // self.presentViewController(alert, animated: true, completion: nil)
  13. self.present(alert, animated: true, completion: nil)
  14. })
  15. manager.requestAlwaysAuthorization()
  16. manager.requestWhenInUseAuthorization()
  17.  
  18. }
  19. // manager.startUpdatingHeading()
  20. manager.startMonitoringSignificantLocationChanges()
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement