openSettingsURLString | Apple Developer Documentation
The URL string you use to deep link to your app’s custom settings in the Settings app.
developer.apple.com
if let url = URL(string: UIApplication.openSettingsURLString){
UIApplication.shared.open(url)
}
응용
swift]앱에서 디바이스 환경설정 - 해당 앱 알림 설정 창 화면에 띄우는 방법
UNUserNotificationCenter.current().getNotificationSettings { (settings) in guard settings.authorizationStatus == .authorized else{ let alert = UIAlertController(title: "알림", message: "기기 내 [설정]>[앱 이름]>[알림]에서\n알림을 허용해
dev-geeyong.tistory.com
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
guard settings.authorizationStatus == .authorized else{
let alert = UIAlertController(title: "알림", message: "기기 내 [설정]>[앱 이름]>[알림]에서\n알림을 허용해주세요.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "취소", style: .cancel, handler: nil))
alert.addAction(UIAlertAction(title: "확인", style: .default, handler: { _ in
DispatchQueue.main.async {
let settingUrl = NSURL(string: UIApplication.openSettingsURLString)!
if UIApplication.shared.canOpenURL(settingUrl as URL){
UIApplication.shared.open(settingUrl as URL, options: self.convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: { (istrue) in
})
}
}
}))
self.present(alert, animated: true)
return
}
func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}728x90
'Develop > Swift' 카테고리의 다른 글
| [Swift] for문 역으로 순회방법 (0) | 2025.11.05 |
|---|---|
| [Swift] ARC(Automatic Reference Counting) (1) | 2025.08.18 |
| [iOS] WKUIDelegate (0) | 2024.03.16 |
| [iOS] WKNavigationDelegate (0) | 2024.03.16 |
| [Swift] Calendar (0) | 2024.03.09 |