Notification setting ON/OFF Screen

1.3k Views Asked by At

How to open iOS app notification toggle (on/off) screen within device notification setting programmatically?

I have checked UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!), but it opens only app root setting, not a notification sub section.

2

There are 2 best solutions below

0
franiis On

I'm afraid it impossible in reliable way.

You can try:

UIApplication.shared.open(URL(string:"App-Prefs:root=NOTIFICATIONS_ID")!, options: [:], completionHandler: nil)

as stated here: https://stackoverflow.com/a/49041704/5226328 but it can be rejected by Apple.

0
Anuraj On

You cannot open sub section. Using this you can only navigate to app's setting.

if let appSettings = URL(string: UIApplicationOpenSettingsURLString + Bundle.main.bundleIdentifier!) {
         if UIApplication.shared.canOpenURL(appSettings) {
       UIApplication.shared.open(appSettings)
  }

}