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.
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 developed one application which use Skype URI for dial the tel number.
NSString* stringURL = [NSString stringWithFormat:#"skype:%#", strTel];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:stringURL]];
But the Skype URI doesn't work.
I remembered it worked before.
Now, it only opened Skype, and nothing happens (It used to dial the tel number before).
I checked the skype document, but seems nothing change.
Did I miss anything?
Please help me to solve this issue.
PS: I already added the key LSApplicationQueriesSchemes in Info.plist file for skype
Firsly check skype is in your device or not. You can use below code for Skype and check real device.
BOOL skypeInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"skype:"]];
if(skypeInstalled){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"skype:echo123?call"]];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://itunes.apple.com/in/app/skype/id304878510?mt=8"]];
}
Or Use as this
NSString* urlString = [NSString stringWithFormat:#"skype:USER_NAME?call"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]];
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];
}
}
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 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.