Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
- if status == .notDetermined || status == .denied || status == .authorizedWhenInUse {
- // present an alert indicating location authorization required
- // and offer to take the user to Settings for the app via
- // UIApplication -openUrl: and UIApplicationOpenSettingsURLString
- DispatchQueue.main.async(execute: {
- 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)
- alert.addAction(UIAlertAction(title: "Go to Settings now", style: UIAlertActionStyle.default, handler: { (alert: UIAlertAction!) in
- print("")
- UIApplication.shared.openURL(NSURL(string:UIApplicationOpenSettingsURLString)! as URL)
- }))
- // self.presentViewController(alert, animated: true, completion: nil)
- self.present(alert, animated: true, completion: nil)
- })
- manager.requestAlwaysAuthorization()
- manager.requestWhenInUseAuthorization()
- }
- // manager.startUpdatingHeading()
- manager.startMonitoringSignificantLocationChanges()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement