-1

I´m new in SwiftUI. I want to know how can I open the App Settings in the Setting App from the iPhone, when the user push a Button in the App.

lula08
  • 195
  • 2
  • 11

1 Answers1

4

Based on this, you can use the following sample code:

import SwiftUI

struct ContentView: View {
    var body: some View {
        Button(action: {self.settingsOpener()} ){
            Text("Open Settings")
            
        }
    }
    
    private func settingsOpener(){
        if let url = URL(string: UIApplication.openSettingsURLString) {
            if UIApplication.shared.canOpenURL(url) {
                UIApplication.shared.open(url, options: [:], completionHandler: nil)
            }
        }
    }
}
Khashayar
  • 357
  • 3
  • 12