In the case that a user may accidentally declines to receive notifications and wants to turn notifications later, how can I use an NSURL to open the IOS Settings App to my app's notification page where they can select Allow Notifications?
-
4`UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)` – duan Mar 17 '17 at 03:14
-
Possible duplicate of [Opening the Settings app from another app](http://stackoverflow.com/questions/5655674/opening-the-settings-app-from-another-app) – duan Mar 17 '17 at 03:15
-
@Matt did you ever find a solution for this? – Nick Cuypers Jan 17 '19 at 13:39
6 Answers
Updated 8 Dec, 2021:
This method will open Settings > Your App. It will show all available privacy toggles like camera, photos, notifications, cellular data, etc.
After a comment from @Mischa below, tested and updated the answer to this (more succinct):
if let appSettings = URL(string: UIApplication.openSettingsURLString), UIApplication.shared.canOpenURL(appSettings) {
UIApplication.shared.open(appSettings)
}
Previous answer:
I found the answer to this question (albeit helpful) has a bit too much assumed logic. Here is a plain and simple Swift 5 implementation if anyone else stumbles upon this question:
if let bundleIdentifier = Bundle.main.bundleIdentifier, let appSettings = URL(string: UIApplication.openSettingsURLString + bundleIdentifier) {
if UIApplication.shared.canOpenURL(appSettings) {
UIApplication.shared.open(appSettings)
}
}
-
1
-
3This opens the app settings, but not the app notification settings. I wonder if there's an Apple approved way to do that. – SudoPlz Jul 02 '21 at 10:31
-
1@SudoPlz No, there is no (public) way to access subpages of your app's settings page. But your users will understand as they immediately see the "Notifications" option on the main page. – Mischa Sep 15 '21 at 15:21
-
1I wonder why this answer appends the `bundleIdentifier` to the actual settings URL. Is there an actual reason for that? The URL created from `UIApplication.openSettingsURLString` opens the app settings as well and it seems obsolete. In other words: The simplest solution is [Eric Yuan's answer](https://stackoverflow.com/a/68170742/2062785). Apple's documentation of the property states the same: _"When you open the URL built from this string, the system launches the Settings app and displays the app’s custom settings, if it has any. Use this string with `open(_:options:completionHandler:)`."_ – Mischa Sep 15 '21 at 15:23
-
1Mischa, you are probably right, it might have been the case that back when I wrote this answer it needed the bundle identifier, but possibly not anymore. I'll give it a check in a moment and update my answer if that's the case. Thanks for pointing it out! – Gligor Sep 17 '21 at 01:03
For Swift 3, use UIApplicationOpenSettingsURLString
to go to settings for your app where it shows the Notifications status and "Cellular Data"
let settingsButton = NSLocalizedString("Settings", comment: "")
let cancelButton = NSLocalizedString("Cancel", comment: "")
let message = NSLocalizedString("Your need to give a permission from notification settings.", comment: "")
let goToSettingsAlert = UIAlertController(title: "", message: message, preferredStyle: UIAlertControllerStyle.alert)
goToSettingsAlert.addAction(UIAlertAction(title: settingsButton, style: .destructive, handler: { (action: UIAlertAction) in
DispatchQueue.main.async {
guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(settingsUrl) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: \(success)") // Prints true
})
} else {
UIApplication.shared.openURL(settingsUrl as URL)
}
}
}
}))
logoutUserAlert.addAction(UIAlertAction(title: cancelButton, style: .cancel, handler: nil))

- 30,606
- 13
- 135
- 162

- 4,431
- 43
- 36
-
19It opens Setting's page. But the question is asking for App's notification's page. – Chanchal Raj Jul 13 '18 at 11:44
-
2@ChanchalRaj, yea there is no way to do that. Settings is close as you are going to get. – CodeOverRide Feb 28 '19 at 02:01
-
6
Swift 5:
if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(url)
}

- 1,213
- 11
- 13
This should keep you covered for all iOS versions, including iOS 15 and iOS 16.
extension UIApplication {
private static let notificationSettingsURLString: String? = {
if #available(iOS 16, *) {
return UIApplication.openNotificationSettingsURLString
}
if #available(iOS 15.4, *) {
return UIApplicationOpenNotificationSettingsURLString
}
if #available(iOS 8.0, *) {
// just opens settings
return UIApplication.openSettingsURLString
}
// lol bruh
return nil
}()
private static let appNotificationSettingsURL = URL(
string: notificationSettingsURLString ?? ""
)
func openAppNotificationSettings() -> Bool {
guard
let url = UIApplication.appNotificationSettingsURL,
self.canOpen(url) else { return false }
return self.open(url)
}
}
Usage:
Button {
let opened = UIApplication.shared.openAppNotificationSettings()
if !opened {
print("lol fail")
}
} label: {
Text("Notifications")
}

- 6,116
- 7
- 48
- 77
Since iOS 15.4 we can deeplink to the notif settings screen directly using UIApplicationOpenNotificationSettingsURLString
:

- 550
- 10
- 18
UPDATE: This will be rejected by Apple.
To open notifications part of settings use this
UIApplication.shared.open(URL(string:"App-Prefs:root=NOTIFICATIONS_ID")!, options: [:], completionHandler: nil)

- 398
- 5
- 14
-
6This will be rejected by Apple: "Your app uses the "prefs:root=" non-public URL scheme, which is a private entity. The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change." – nurider Apr 28 '18 at 12:19
-
1@nurider We've had an app in the App Store for 2 years which uses "prefs:root=" – Leon Jul 03 '18 at 16:04
-
This just brings me to my app's settings page; not the notifications page. Does this still work for you? For me it's the same as using UIApplicationOpenSettingsURLString. iOS 12.something, Xcode 10.something. – Darren Black Jan 31 '19 at 17:37
-
@DarrenBlack Correct I don't believe this is possible anymore on iOS 12. – ttorbik Feb 01 '19 at 16:16
-