Custom URL Scheme for Settings on iOS 10?
Asked Answered
S

3

7

Any Idea what happened to the Setting's Custom URL Scheme on iOS 10? Is Apple still giving acess to third-pary apps to launch iOS Settings from the app via URL Scheme on iOS10? The Old URL scheme are not working anymore!

Stockholm answered 21/6, 2016 at 9:24 Comment(0)
M
10

None of the previous methods for launching the root "Settings" app on iOS 8+ were officially supported by Apple, so unfortunately we can't rely on them. It's also possible that apps that relied on the undocumented behaviors could be rejected during App Store review, even if others have been approved--even if the same app had been previously approved!

I've been unable to discover any workaround either, so it seems your choices are:

  1. Open the app-specific URL (as detailed in many places, including @alvin-varghese 's answer above), and then ask the user to navigate backwards. (A terrible user experience, since it involves the user knowing to scroll up from the app list into the main settings sections.)

  2. Use an instructional screen or alert in your app to educate users on how to find it themselves. (Not much better, but at least aren't dropped into an unfamiliar context with no waypoints.)

There doesn't seem to be an officially supported way of making this happen in iOS 10, and as you pointed out, it seems like the old ways (adding prefs scheme to your Info.plist file and using openURL(_:)) do not work any more.

Maillol answered 26/7, 2016 at 21:36 Comment(3)
Hi there! Do you know a non-public way for Enterprise Apps to make a "deep shortcut"?Hermaphrodite
FWIW, a URL string of "App-Prefs:root" opens to the Settings app’s home view (as opposed to your app’s settings page). Not quite ideal, but better than asking the user to hit the Back button first.Tanney
Update: I can now open the Settings app directly to a specific page by following Vandit Mehta's directions below. (Basically, add “prefs” to your URL schemes in the app’s plist; see below.)Tanney
K
5

From iOS 10 some of the things are changed,

So, for something like bluetooth you need to write below lines of code,

Swift 3.0 :

func openBluetoothSettings(){
        let urlBTSet = URL(string: "App-Prefs:root=Bluetooth")
        let objApp = UIApplication.shared
        objApp.openURL(urlBTSet!)
    }

Objective-c

-(void) openBluetoothSettings{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Bluetooth"]];
}

So, In above code what they have changed is string need to add "App-Prefs:root=Bluetooth" (This the example of opening bluetooth settings)

Don't forgot : 'Goto taget -> info -> URL Types -> Add "prefs" in URL Schemes'

Kimball answered 27/1, 2017 at 13:36 Comment(6)
I tried your string, it didn't work for me (the Bluetooth page didn't open). However, it did launch the Setting app into its home page. This is better in some cases than opening up to your app's settings page.Tanney
You are testing with iOS 10 and above right? and in swift or objective-c?Kimball
Yes tested in iPhone 6Kimball
Have you added URL Schemes ? if not please add 'Goto taget -> info -> URL Types -> Add "prefs" in URL Schemes'Kimball
Thank you! Got it to work after updating the app’s plist. Maybe add the bit of info to your answer?Tanney
This is now forbidden by Apple ("Your app uses the "prefs:root=" non-public URL scheme, which is a private entity.". Your app will be rejected if you use it.Mcclintock
D
1

Use this one, it works.

if let url = URL(string: UIApplicationOpenSettingsURLString) {
   UIApplication.shared().open(url, options: [:], completionHandler: nil)
 }
Dutchman answered 21/6, 2016 at 20:49 Comment(2)
Hi Alvin, I'm asking about opening iOS Settings like Wifi or Cellular which are previously working: prefs:root=General&path=About but it is no longer working in iOS 10Stockholm
I think, they still work with Extensions. Ex app is Magic Launcher in Appstore.Homonym

© 2022 - 2024 — McMap. All rights reserved.