13

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 .

Sahil Kapoor
  • 11,183
  • 13
  • 64
  • 87
vijeesh
  • 1,317
  • 1
  • 17
  • 32
  • 2
    Opening preference pages apart from your own app's preferences has not been permitted for some time. It seems that in iOS 10 Apple have further enforced this restriction. – Paulw11 Jun 22 '16 at 06:56
  • Thanks, @Paulw11 . As my clients are waiting on this , it would be grateful if you could also provide me more details on this , so that I can explain my clients the same . – vijeesh Jun 22 '16 at 07:12
  • 1
    Preferences URLs were removed in iOS 5.1. I am surprised that your code has been working at all - http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme – Paulw11 Jun 22 '16 at 07:15
  • Indeed and that is discussed in the answer I linked to, but that is not what you are trying to do – Paulw11 Jun 23 '16 at 07:57

3 Answers3

11

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];
Croath
  • 156
  • 2
  • 6
  • Can you please send me the link of apple review process were this rule is mentioned because when I went through their documentation on review process I couldn't find this . – vijeesh Jun 23 '16 at 11:14
  • 6
    Sorry there's no link about it. The App Store Review Team gave me a phone call to explain it, and as you did, I asked where the rule is, in the review guideline or somewhere else? They just said, it's the rule, it's not written anywhere and that's why I give you a phone call to tell you it's a new rule, and the rule will not be public, at least not being public for now. BTW, it was really a terrible call, which feels like that "I'm your dad it's the rule because I say it's a rule". – Croath Jul 13 '16 at 09:08
  • Ah, good old Apple. Making their customers suffer since 2007. – phreakhead Sep 16 '16 at 20:56
  • It's not really a new rule as it falls under rule 2.5.1: Apps may only use public APIs. The problem is the MAY, should be a MUST ;-). – grandouassou Oct 13 '16 at 11:40
  • Did you have the solution in the end of 2016? – Nam Vu Dec 08 '16 at 04:40
5

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")!)
}
Bona Fide
  • 714
  • 1
  • 9
  • 33
-2

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

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

Joeytat
  • 7
  • 2