是否可以在 watchOS 中以编程方式打开“设置”应用程序?

Mat*_*evi 8 xcode swift watchos

我目前正在使用 Swift 为 watchOS 7+ 编写一个独立的 Apple Watch 应用程序。我的应用程序使用位置服务,如果用户一开始不允许这样做,我希望在我的 watchOS 应用程序内有一个按钮,将我的用户发送到“设置”应用程序的部分(在 watchOS 内),他可以在其中提供应用程序的适当权限。

我知道在 iOS/macOS 中,您可以使用UIApplication 中的openSettingsURLString字符串来执行我想要的操作,但它在 watchOS 中不可用,并且我没有在 WKExtension 类中找到任何等效资源(通常相当于 watchOS 环境中的 UIApplication ,如此处讨论的

有谁知道是否有任何方法可以从我的 watchOS 应用程序以编程方式打开 Apple Watch 设置应用程序?

下面的代码是我想要做的 - 但是(当然)它崩溃了,因为我实际上没有传递任何 systemURL。

.alert(isPresented: $alertVisible) {
                Alert (title: Text("Please allow our app to use location services in order to get Weather Data"),
                       message: Text("Go to Settings?"),
                       primaryButton: .default(Text("Settings"), action: {
                    WKExtension.shared().openSystemURL(URL(string: "")!)
                    //UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
                }),

Run Code Online (Sandbox Code Playgroud)