Navigate to settings screen in iphone - iphone

I want to move from my app to settings screen of iphone when a button in the app is pressed. Can any one please help by telling how to do it? Any help is appreciated. Sorry for my bad english.
Thanks

prefs:root=General pattern no longer works for iOS Latest versions !!!
There is an update in it. The following works fine in iOS 8 ..
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General"]];
you may look at this
iOS Launching Settings -> Restrictions URL Scheme

Settings screen can be opened for versions less than IOS 5.0 as it has been disabled for latest IOS's. For Lower versions you can try this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];
MoreOver you should create your own view and present the editable settings to the user and get the input from him(for the first time or as a menu) and store it using NSUserdefaults.
You can't ask user to enter settings such as server-address port etc and try it each time, if it works.

I have found a solution for navigating from your application to Settings application which works fine iOS 8 or later versions
1) [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
This will navigate to settings only if your app settings are absent
if they are present then the above code will navigate to Settings page of your app
I am using the below string to navigate to iCloud page and it works fine
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:#"App-Prefs:root=CASTLE"] options:#{} completionHandler:nil]
just by replacing the "CASTLE" with "GENERAL"

Related

Open Settings → Wifi from alert button action in iOS 5.1

I want to open Settings from my app's alertView button action with following URL Scheme.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General&path=Network"]];
It's working fine for iOS 5.0 but not for 5.1 and above.
Any alternate way to implement this?
Simply no. This URL scheme has been disabled by Apple in SDK 5.1. Its not possible without Jailbreak.
This feature is no more supported in iOS 5.1 and above. No direct way to do this.

Re-enabling location services for iPhone app

I have been struggling with the location service request for my iPhone app. If the user says "Don't allow", I'm stuck in my "this app needs location services in order to work"...
All attempts to re-apply for location services have been fruitless, which several stacks here can testify to.
Then I read that the only way to re-enable the location services was to redirect the user to the location service settings using this :
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"]];
But even that doesn't seem to work (iPhone 4 and 4S, both on 5.1)
Is there really no other way, except telling the user to go to preferences and then guiding him through ? It seems so toe-twistingly bulky to me.
If the user turned the location service off, there is no other way then to tell the user to turn them on again.
You could try to redirect, but this is only possible on iOS 5.0. So you can do it like:
NSURL *prefsURL = [NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"];
if ([[UIApplication sharedApplication] canOpenURL:prefsURL]) {
[[UIApplication sharedApplication] openURL:prefsURL];
} else {
// Can't redirect user to settings, display alert view
UIAlertView *alertView = ....
}

Opening IOS settings preferences

Im having a problem opening the settings preferences in my IOS iphone app. At the moment im just using a simple button to test and it doesn't seem to be working correctly.
Basically when I click the button I want a specific settings preference page to open. This is what Im currently using within my buttons IBACTION:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General"]];
Hope you guys can help me out with a solution for this, thanks in advance.
try this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];
should work in iOS 5
... update:
opening with the prefs url was disabled in iOS 5.1
sebastian

Access Settings app in iOS

Is there an opportinity to show up the settings.app in iOS by clicking on a button? It should work with iOS 5.1 so the "prefs:root..." url is no option.
Do you have an idea how to solve this?
I know the question is about 5.1 specifically, but in case anyone else is interested:
As of iOS 8, it is possible to take a user from your app directly into the Settings app. They will be deep linked into your app's specific Settings page, but they can back out into the top level Settings screen.
UPDATE:
Thanks to Pavel's comment, I simplified the if statement and avoided the EXC_BAD_ACCESS on iOS 7.
UPDATE 2:
If your deployment target is set to 8.0 or above, Xcode 6.3 will give you the following warning:
Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true
This is because the feature was available starting in 8.0, so this pointer will never be NULL. If your deployment target is 8.0+, just remove the if statement below.
if (&UIApplicationOpenSettingsURLString != NULL) {
NSURL *appSettings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:appSettings];
}
You are not able to do this on iOS 5.1. Most likely Apple removed that ability intentionally (you'll get "Please enter a valid URL", while Twitter can still call the Settings, though). Please refer to:
How to open preferences/settings with iOS 5.1?.
Apple Disables Home Screen Shortcuts For Settings Toggles In iOS 5.1
On iOS 8 Apple gave us the possibility to go to the App Settings right from our app
you can apply this code:
- (IBAction)openSettings:(id)sender {
BOOL canOpenSettings = (UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
}
iOS6 shows an option to open the settings app directly from an 'AlertView' (shown automatically) if it detects if you're trying to post to FB or Twitter without having those accounts setup.
I have elaborated this over here
The method openURL: is now deprecated.
iOS 10 +
The correct way to open the settings URL (or any URL for that matter) is as follows:
NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:settingsURL options:#{} completionHandler:^(BOOL success) {
// Do anything here
}];

iPhone: Opening Application Preferences Panel From App

Is it possible to open the application's preferences pane directly from the app, or will users be forced to to go through the Settings app?
The nicer alternative is to use InAppSettingsKit which does the replication for you. Apple wants everybody to use the Settings app though.
You can use this on iOS 5.0 - 5.0.1.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];
It is possible now in iOS 8
if (&UIApplicationOpenSettingsURLString != NULL)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
They have to go through the Settings app.
An alternative is for you to replicate the settings within your application.