How to Open Keyboard's settings screen programmatically in iOS 10?
This code is not working in iOS 10
NSURL *keyboardSettingsURL = [NSURL URLWithString: #"prefs:root=General&path=Keyboard/KEYBOARDS"];
[[UIApplication sharedApplication] openURL:keyboardSettingsURL];
and added URL Scheme
It looks like this functionality has been disabled in iOS 10. I believe that https://developer.apple.com/library/content/qa/qa1924/_index.html is no longer valid. I checked several top keyboard apps and they have either been updated to no longer have a direct link to the preferences, or have a non-working button.
is work in iOS 10+
NSURL *keboardURL = [NSURL URLWithString: #"App-Prefs:root=General&path=Keyboard/KEYBOARDS"];
[[UIApplication sharedApplication] openURL:keyboardURL];
key points:
#"App-Prefs:root=General&path=Keyboard/KEYBOARDS"
You may need to add a URL Scheme to your project if you haven't already. Instructions and more details can be found at this Apple Q&A Reference. Hope this helps!
In iOS 10, a new url is required. Try using this code which tests both urls :
NSArray* urlStrings = #[#"prefs:root=General&path=Keyboard/KEYBOARDS", #"App-Prefs:root=General&path=Keyboard/KEYBOARDS"];
for(NSString* urlString in urlStrings){
NSURL* url = [NSURL URLWithString:urlString];
if([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL:url];
break;
}
}
For IOS-10 or higher,openURL is deprecated. use with completion handler like below.
NSString *settingsUrl= #"App-Prefs:root=General&path=Keyboard";
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0){
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:settingsUrl]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:settingsUrl] options:#{} completionHandler:nil];
}
}
Related
I'm using this code to redirect to iOS settings for the location:
NSURL *url = [NSURL URLWithString:#"App-Prefs:root=LOCATION_SERVICES"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:#{} completionHandler:nil];
}
But it is just redirecting to settings and not in location or bluetooth settings. Does anybody know if is any way to redirect to iOS location settings?
Thank you
Declare url as:
NSURL *url = [NSURL URLWithString:#"App-Prefs:root=LOCATION_SERVICES"];
thus:
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL: url];
}
NOTE:
The above approach should work for iOS 10.x and below (you could check: How to programmatically open the WIFI settings in Objective-C on iOS 10). However, the "app-prefs" URL scheme is not supported by Apple! prefs URLs are considered as private APIs, the only documented preference URL is the UIApplicationOpenSettingsURLString. Obviously, is has nothing to do with the used programming language; Related:
Swift 4 - IOS 11 / “Apps-prefs=root” function not working
IOS 11 / "Apps-prefs=root" function not working after update to Swift 3
Roughly speaking, you are not able to do such a navigation anymore on iOS 11.
First: Click on project name >> target>> Info >> url Types >> URL Schemes.
For example you can see the screenshot.
Then use the code:
-(IBAction)openSettingViewToEnableLocationService:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"]];
}
You can use UIApplicationOpenSettingsURLString. If your application uses location data or bluetooth you will see location and bluetooth settings there.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
I have my old application which is working fine till iOS 8.2. In one button action I have to open safari using openUrl and this is working fine for the device with iOS 8.2. But when I run it in iOS 8.3 then its not opening the safari and when I tried to print it then its returning NO.
Is there any change in iOS 8.3 for openUrl method?
Edit 1:
NSString *loginUrl=[object sighnUpUrl];
NSLog(#"%d",[[UIApplication sharedApplication] openURL:[NSURL URLWithString:loginUrl]]);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:loginUrl]];
I am just using the url of login page of my web.
Edit 2:
NSURL *url = [NSURL URLWithString:#"http://www.stackoverflow.com"];
if (![[UIApplication sharedApplication] openURL:url]) {
NSLog(#"%#%#",#"Failed to open url:",[url description]);
}
I tried the same code and getting Failed to open url:http://www.stackoverflow.com.
Edit 3:
NSURL *URL = [NSURL URLWithString:#"http://www.google.de"];
if ([[UIApplication sharedApplication] canOpenURL:URL]) {
[[UIApplication sharedApplication] openURL:URL];
}
When I tried the same above code then its entering the if block but still unable to the safari.
Note: All the above Codes are working in iOS 8.2.
this is the way to go:
NSURL *URL = [NSURL URLWithString:#"http://www.google.de"];
if ([[UIApplication sharedApplication] canOpenURL:URL]) {
[[UIApplication sharedApplication] openURL:URL];
}
Check this
NSURL *url = [NSURL URLWithString:#"http://www.stackoverflow.com"];
if (![[UIApplication sharedApplication] openURL:url]) {
NSLog(#"%#%#",#"Failed to open url:",[url description]);
}
Please try this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.google.com"]];
Edit:
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:yourURL];
Try to place your URL here & check whether it returns True or False.
I have gone through all the answers and I know all of them will work.The issue was on the other side.I am using Mobile Device Management in my app.Some one from the server side had disabled safari using MDM.Unfortunately for the device with iOS 8.2 it was enabled and for the devices with iOS 8.3 it was disabled which made me think its an iOS issue.So while safari is disabled using MDM it can't open any url.My Bad.Thanks for all your answers.
ios8.3 .apk file received by e-mail, can not open other applications, it may be a BUG ios8.3 of
I'm not inventing the wheel. In iOS8, to open Settings from inside the app I'm using this code:
BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings)
{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
The code is in a lot of answers and questions in stackoverflow.
The problem came out with Xcode 6.3, I've got a warning saying:
Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true
What is interesting is that Apple is using it in their example code:
https://developer.apple.com/library/ios/samplecode/AppPrefs/Listings/RootViewController_m.html
Some idea about how to avoid the warning and still checking if I can open Settings?
SOLVED:
The problem is related with the Deployment Target in the App.
If the Target is 8.0 or above, the comparison will be always true because you are always over 8.0. So we do not need the if verification:
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
Another option can be:
NSURL *settings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:settings])
{
[[UIApplication sharedApplication] openURL:settings];
}
I believe this is because &UIApplicationOpenSettingsURLString is never nil in this version so you can just directly use the following to launch settings:
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
I'm working on iOS application. Here is the code i used
NSURL *url = [NSURL URLWithString:#"fb://page/5718758966"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
else
{
//Open the url as usual
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://facebook.com/5718758966"]];
}
As I mentioned, this code has worked to open Facebook app but shows blank page; my question is if there is an alternative link I can use that will both open the app and direct the user to this specific page, or is this simply a Facebook bug?
Thanks!
Instead of "fb://page/5718758966" try "fb://profile/5718758966" for your URL.
Is this is the only way to open a dialer to call or msg.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:+%#",phoneNumber]]];
if yes. then will this support from ios3 to ios6 (beta).
if no. then can any one please give some sample code.(if any private api can do this pls mention it)
if separate functions are available for sending sms and calling a number, please let me know that too.
in ipad 1 with ios 4.2.6, the following codes are not working
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"sms:9190432097420"]]];
and
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:9190432097420"]]]
Wr does the problem lies
According to UIApplication's Class Reference, the openUrl: method is available in iOS 2.0 and later. So you should be safe to use that method.
With regard to your example, it's 'safer' if you first check if there is an application that can handle the provided url. For instance:
NSURL *url = [NSURL URLWithString:#"tel:9190432097420"];
if([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
else {
NSLog(#"No application for url '%#'", url);
}
Are you testing on an actual device or in the simulator? The simulator does not support this as far as I've seen.