Reputation: 1783
I recently have an app summited to the app store and they refused to approve the following code I used open phone settings:
let url:NSURL! = NSURL(string : "prefs:root=")
UIApplication.sharedApplication().openURL(url)
So I got the following code (How do i open phone settings when a button is clicked ios) and got it approved:
UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
Unfortunately it does not do what I really need as it opens my application settings sometimes and other times it opens the phone settings.
And I need something to open just & only the phone settings instead.
Upvotes: 1
Views: 7676
Reputation: 1369
In iOS 10, "prefs" must be replaced with "App-Prefs". You can then use this code which tests over all the possible urls.
NSArray* urlStrings = @[@"prefs:root=<your_path>", @"App-Prefs:root=<your_path>"];
for(NSString* urlString in urlStrings){
NSURL* url = [NSURL URLWithString:urlString];
if([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL:url];
break;
}
}
Upvotes: 1
Reputation: 631
This will open the Settings page like shown below.
UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=Settings")!)
But unfortunately, use of this code in your application leads to rejection on the review process (see the comments).
Upvotes: 1