我正在创建一个基于位置的应用程序,当用户拒绝位置访问时,会弹出一个警报视图,要求用户转到设置页面并更新设置以允许位置访问。如果用户允许访问然后按回,则视图不会使用允许更新位置的更新设置刷新。
是否有可以在用户从设置页面返回应用程序后运行的功能,该功能将刷新并开始更新位置。
我感谢任何建议或帮助。谢谢你。
func alertForNoLocationAccess(){
let alert = UIAlertController(title: "Allow Location Access", message: "Cannot add location data and map coordinates to your entries without access. Press settings to update or cancel to deny access.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Settings", style: .default, handler: { action in
if let url = URL(string:UIApplication.openSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(alert, …Run Code Online (Sandbox Code Playgroud)