如果禁用,我需要讓用戶啟??用位置服務。我創建了一個警報,詢問用戶是否要啟用位置。我用戶單擊確定我想在 iPhone 上打開定位服務頁面,如下所示:

我正在嘗試“openSettingsURLString”,但它會打開應用程式設定而不是位置服務頁面,這是代碼:
let url = URL(string: UIApplication.openSettingsURLString)
let settingsAction = UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default) {
(UIAlertAction) in UIApplication.shared.open(url!, options: [:], completionHandler: nil)
self.dismiss(animated: true, completion: nil)
}
alertController.addAction(cancelAction)
alertController.addAction(settingsAction)
self.present(alertController, animated: true, completion: nil)
uj5u.com熱心網友回復:
??注意
有一種方法可以實作以下目標。但是,從 iOS 12 開始,Apple 開始拒絕使用
App-Prefs或prefs:root兩種方法都基于未記錄 API 的應用程式。
打開設定應用程式-這個應該可以使用。
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
開放定位服務
如果此應用僅供個人使用,并且您不打算將其提交到 App Store,那么您應該可以使用以下內容。否則,如果您確實計劃發布您的應用程式,Apple 將在審核后拒絕它。
UIApplication.shared.open(URL(string: "App-prefs:LOCATION_SERVICES")!)
uj5u.com熱心網友回復:
我相信這是不可能的,您只能導航到應用程式本身的設定;蘋果希望用戶自己導航到定位服務。. 我建議向用戶提供有關如何導航到位置服務的說明,例如一些螢屏截圖和它們應該采用的路徑。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/421198.html
標籤:
