我跟踪用户的位置,并在我的加载首次加载时请求许可:
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
如果用户拒绝,但后来通过在我的应用程序中启用配置选项改变了主意,我该如何再次询问?例如,我有一个自动检测用户位置的switch ,所以当他们启用它时,我会try 这样做:
@IBAction func gpsChanged(sender: UISwitch) {
// Request permission for auto geolocation if applicable
if sender.on {
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
}
}
但这段代码似乎没有任何作用.我希望它能再次询问用户是否允许应用程序跟踪用户的位置.这可能吗?