iOS swift 获取对应APP定位权限是否打开并引导用户打开

xiaoxiao2021-02-28  90

if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) { if isLocationServiceOpen() { let alertCon = UIAlertController.init(title: "端末位置坐标没有被允许,引导用户去设置打开坐标", message: nil, preferredStyle: .alert) let cancelAction = UIAlertAction.init(title: " キヤンセル", style: .cancel, handler: nil) let okAction = UIAlertAction.init(title: "设定", style: .default, handler: { (action) in UIApplication.shared.openURL(appSettings as URL) }) alertCon.addAction(cancelAction) alertCon.addAction(okAction) self.present(alertCon, animated: true, completion: nil) } } func isLocationServiceOpen() -> Bool { if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.denied { return true } else { return false } }
转载请注明原文地址: https://www.6miu.com/read-22708.html

最新回复(0)