Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

swift - The "prefs" URL Scheme is not working in iOS 10 (Beta 1 & 2)

I can't get the "prefs" URL Scheme to work in iOS 10 (Beta 1).
It's set up correctly since the same App works fine on iOS 9.

Is this a bug or did it get renamed / removed?

Code:

let settingsUrl = NSURL(string: "prefs:root=SOMETHING")
if let url = settingsUrl {
    UIApplication.sharedApplication().openURL(url)
}

Update: (Beta 2)
Still not working in Beta 2.
It seams to be an bug. For example if you want do invite someone using GameCenter in iOS 10 and you're not logged into iMessage, you'll get a popup asking you to log in. But the "Settings" button does absolutely nothing.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just replace prefs to App-Prefs for iOS 10

Below code works for iOS 8,9,10

Swift 3.0 and Xcode >= 8.1

if #available(iOS 10.0, *)
{
       UIApplication.shared.openURL(URL(string: "App-Prefs:root=SOMETHING")!)
}
else
{
       UIApplication.shared.openURL(URL(string: "prefs:root=SOMETHING")!)
}

Swift 2.2

if #available(iOS 10.0, *)
{
      UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root=SOMETHING")!)
}
else
{        
    UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=SOMETHING")!)
}

Works for me.

Happy Coding ??


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...