openSettings(for:)
Category: Type Method
Platforms: iOS 18.0+, iPadOS 18.0+, Mac Catalyst 18.0+, macOS 15.0+, tvOS 18.0+, visionOS 2.0+, watchOS 11.0+
Overview
Opens the Settings app to a specific section of Accessibility settings.
Declaration
static func openSettings(for feature: AccessibilitySettings.Feature) async throws
Details
See Also
- Opening the Settings app
- enum Feature
open Settings(for:)
Discussion
Some app behaviors depend on a person turning on a specific Accessibility setting on their device. You can use this method to open the Settings app to a specific Accessibility setting to help people turn it on more quickly, as shown in the following code example.
ContentView()
.alert(
"Use Personal Voice",
isPresented: $showAlert
) {
Button("Open Accessibility Settings") {
Task {
do {
try await AccessibilitySettings.openSettings(for: .personalVoiceAllowAppsToRequestToUse)
} catch {
print("Error: \(error)")
}
Button("Cancel", role: .cancel) { }
} message: {
Text("To use this feature, turn on the Personal Voice > Allow Apps to Request to Use setting.")
}
Topics (Grouped)
Opening the Settings app
- Feature — enum; Constants that describe specific Accessibility settings in the Settings app.
Code Examples
static func openSettings(for feature: AccessibilitySettings.Feature) async throws
ContentView()
.alert(
"Use Personal Voice",
isPresented: $showAlert
) {
Button("Open Accessibility Settings") {
Task {
do {
try await AccessibilitySettings.openSettings(for: .personalVoiceAllowAppsToRequestToUse)
} catch {
print("Error: \(error)")
}
}
}
Button("Cancel", role: .cancel) { }
} message: {
Text("To use this feature, turn on the Personal Voice > Allow Apps to Request to Use setting.")
}
Source: https://developer.apple.com/documentation/accessibility/accessibilitysettings/opensettings(for:)