vijeesh
vijeesh

Reputation: 1335

iOS 10 beta: URL scheme is not working but works in iOS 9

In one particular scenario I am taking the user to passcode settings page . below is the code used for this -

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=PASSCODE"]];

After upgrading to iOS 10 beta version I am no longer taken to settings passcode page instead it terminates the app .

Can anyone please help me with this . Thanks in advance .

Upvotes: 13

Views: 4972

Answers (3)

Abdelaziz Halaouet
Abdelaziz Halaouet

Reputation: 51

The prefs scheme has changed on iOS 10, you can use this :

if #available(iOS 10.0, *) {
    UIApplication.shared.open(URL.init(string:"App-Prefs:root= PASSCODE")!, options: [UIApplicationOpenURLOptionUniversalLinksOnly:true], completionHandler:{(success: Bool?) -> Void in}})
} else {
    // Fallback on earlier versions
    UIApplication.shared.openURL(URL.init(string:"Prefs:root= PASSCODE")!)
}

Upvotes: 5

Croath
Croath

Reputation: 156

No way yet.

About 1 month before iOS 10 beta 1 was released, my app got a rejection because of opening a Preference.app URL. The app review team gave me a phone call to explain it: It's not permitted right now for the reason: Using private API. Only opening current app's setting page(UIApplicationOpenSettingsURLString) is allowed.

So it really makes sense now why they rejected me. Because no one could open system setting since iOS 10.

Updated answer at 8 Dec, 2016:

Using Private API (Don't submit the app with these code to the App Store):

@interface PrivateApi_LSApplicationWorkspace
- (BOOL)openSensitiveURL:(id)arg1 withOptions:(id)arg2;
@end

PrivateApi_LSApplicationWorkspace* _workspace;

_workspace = [NSClassFromString(@"LSApplicationWorkspace") new];

BOOL result = (BOOL)[_workspace openSensitiveURL:[NSURL URLWithString:@"Prefs:root=YOURSETTINGURLHERE"] withOptions:nil];

Upvotes: 11

Joeytat
Joeytat

Reputation: 7

On iOS 10 you can use openURL:options:completionHandler: instead;

Also you can see this article(openURL Deprecated in iOS 10) for more details.

Upvotes: -2

Related Questions