0

There are a few posts on SO about this already, but there seem to be some conflicting views about iOS 10, and if it is / is not possible.

In iOS 10 is it possible to open the phones Settings app from my app? In iOS 10 is it possible to open the phones Settings app and a 'sub' setting e.g. Do Not Disturb? As it was pre iOS10.

I have added 'prefs' to info > URL Types as described in How do i open phone settings when a button is clicked ios I have tried 'Prefs' and 'prefs' Also, the app has requested permission to receive notifications so includes a settings bundle.

The code below opens to the apps settings. But how do I get it to open the phones settings and not go straight to the apps settings?

if #available(iOS 10.0, *) {
        let settingsUrl = NSURL(string:UIApplicationOpenSettingsURLString) as! URL
        UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
        // THIS OPENS THE APPS SETTINGS
    } else {
        // Fallback on earlier versions
    }

if #available(iOS 10.0, *) {
        let specificUrl = NSURL(string: "prefs:root=DO_NOT_DISTURB") as! URL
        UIApplication.shared.open(specificUrl, options: [:], completionHandler: nil)
        // THIS DOES NOT OPEN THE PHONES DO NOT DISTURB SETTINGS.   
    } else {
        // Fallback on earlier versions
        UIApplication.shared.openURL(NSURL(string:"prefs:root=General&path")! as URL) 
        // This works pre iOS10 Swift 3.
    }

Thanks in advance if you can help!

Community
  • 1
  • 1
richc
  • 1,648
  • 5
  • 20
  • 48
  • Possible duplicate of [The "prefs" URL Scheme not woring in iOS 10 (Beta 1 & 2)](http://stackoverflow.com/questions/38064557/the-prefs-url-scheme-not-woring-in-ios-10-beta-1-2) – 123FLO321 Jan 27 '17 at 13:40
  • hi @123FLO321 - I saw that question, but what are the conclusive answers. ? Not possible in iOS10? Prefs v prefs doesn't seem to work. – richc Jan 27 '17 at 14:02
  • 1
    Just got awnsered. Check it out. – 123FLO321 Feb 20 '17 at 01:12
  • Nice one 123FLO321. The code in that answer worked for me! Thanks. – richc Mar 02 '17 at 14:19

0 Answers0