我有requestAlwaysAuthorization
我需要每次跟蹤用戶,如果用戶不接受requestAlwaysAuthorization
我想在應用程序中退出嗎?CLLocation Manager check requestAlwaysAuthorization如果不接受退出應用程序
我該怎麼辦?
我的代碼如下。
import CoreLocation
public var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let altitudeG = locations.last?.altitude
let longitudeG = locations.last?.coordinate.longitude
let latitudeG = locations.last?.coordinate.latitude
print("\(altitudeG) \(longitudeG) \(latitudeG)")
}
旁註:如果您的應用程序只是「退出」,而不是顯示的一個錯誤消息,它會讓蘋果拒絕,如果從App Store。更重要的是,阻止用戶訪問你的應用程序,如果他們不給你一些權限,也是一個拒絕原因。 –