-2

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 Answers2

2

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)
  }

}
Anuraj
  • 1,242
  • 10
  • 25
0

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.

franiis
  • 1,378
  • 1
  • 18
  • 33