Make a phone call from UIWebView without prompt - ios

SCENARIO
I have an app that is a UIWebView, I make some url overriding for requirements.
PROBLEM
To make a call opening url with tel: works weird in iOS7 and iOS8, it makes the phone call direct in the background, but it also ask for the confirmation, so user experience is horrible:
[[UIApplication sharedApplication] openURL:request.URL];
SOLUTION
To solve this issue, I used telprompt. It works nice in all iOS versions:
NSURL *url = [NSURL URLWithString:#"telprompt://637****"];
return [[UIApplication sharedApplication] openURL:url];
But shows this confirmation dialog:
QUESTION
Now, I have a new requirement, to make the phone call without confirmation or prompt. So... There is some way to make a phone call in iOS omitting the confirmation prompt?
I want something like
NSURL *url = [NSURL URLWithString:#"telnoprompt://637******"];
return [[UIApplication sharedApplication] openURL:url];

NSMutableCharacterSet *characterSet =[NSMutableCharacterSet characterSetWithCharactersInString:#" "];
NSArray *arrayOfComponents = [phone_number componentsSeparatedByCharactersInSet:characterSet];
phone_number = [arrayOfComponents componentsJoinedByString:#""];
NSString *phoneURLString = [NSString stringWithFormat:#"tel:%#", phone_number];
NSString *escapedUrlString = [phoneURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *phoneURL = [NSURL URLWithString:escapedUrlString];

Related

IOS SMS Sending using UI Shared Application

I cannot pass phone number to SMS.
NSString *myString = lblMobilePhone.text;
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[NSString stringWithFormat:#"sms://%#",myString]]];
MFMessageComposeView is how you should be doing it.
If you want to do it your way you need to change it to [NSString stringWithFormat:#"sms:%#",myString] (removed the two // from the url)

IOS IBAction button not going to website using URL

i have a button on a view controller and i want to click the button and it goes to a web site.
the website is held on parse.com.
the code as follows
- (IBAction)WebAddressBtn:(id)sender {
NSString *url = [self.exam objectForKey:#"Website"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
NSLog(#"website: %#",url);
}
the NSLog shows Null for the value url
but the data is held at
self.exam objectForKey:#"Website"
NSLog confirms its there
this works and will go to google
- (IBAction)WebAddressBtn:(id)sender {
NSString *url = #"http://www.google.com";
//[self.exam objectForKey:#"Website"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
NSLog(#"website: %#",url);
}
if i try
NSURL *url = [self.exam objectForKey:#"Website"];
url is still showing as Null
but i know the data is in self.exam objectForKey:#"Website
NSLog Output for data
name = "DMK Media & Photography Ltd";
phone1 = 01993835148;
phone2 = 07795966848;
postcode = "OX28 4BT";
products = "<PFRelation: 0x10dc75320>(<00000000 00000000>.(null) -> products)";
website = "http://www.dmkmedia.co.uk";
[UIApplication sharedApplication] openURL wont work properly if it doesnot have properly formatted url. Please check whether your url has "http://"

Sygic URL scheme - App does not open

I am trying to integrate the most popular navigation apps into my app, and all of those I chose work, except for Sygic.
Following this guide, I wrote the code:
NSString *URL = [NSString stringWithFormat:#"com.sygic.aura://coordinate|%f|%f|drive",
self.coordinate.longitude,
self.coordinate.latitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:URL]];
But when the code is run, Sygic doesn't open, nothing happens.
Checking [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"com.sygic.aura://"]] returns YES when the app is installed and NO when it's not (as it should).
I tested using "Sygic Brasil" and "Sygic (All Regions)", version 13, but neither will open.
I also tried percent-escaping the URL string, and that didn't work either.
you try following code,
NSString *URL = [NSString stringWithFormat:#"com.sygic.aura://coordinate|%f|%f|drive",
self.coordinate.longitude,
self.coordinate.latitude];
NSURL *newURL = [NSURL URLWithString:[URL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ];
if(newURL)
{
[[UIApplication sharedApplication] openURL:newURL];
}
else
{
NSLog(#"Something wrong with lat or long or both");
}

Easiest way to share a link as Page from iOS app

What's the easiest way to share a link as a Facebook Page from an iOS app? I don't care if the solution isn't elegant, it's just for an internal tool.
You can try this....
NSString *urlString = #"Your Link";
NSString *shareUrlString = [NSString stringWithFormat:#"https://m.facebook.com/sharer.php?u=%#", urlString];
shareUrlString = [shareUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc] initWithString:shareUrlString];
[[UIApplication sharedApplication] openURL:url];

How can I make phone call in iOS?

How can I make a phone call in Objective-C?
You can initiate a call
https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html
So this would probably work:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:12125551212"] options:#{} completionHandler:nil];
This is clipped from a project I did to do just that:
NSString *phoneStr = [NSString stringWithFormat:#"tel:%#",phone_number];
NSURL *phoneURL = [NSURL URLWithString:phoneStr];
[[UIApplication sharedApplication] openURL:phoneURL];
It may also be helpful to know how to prompt the user to call a number:
NSURL *phoneNumber = [NSURL URLWithString:#"telprompt://13232222222"];
[[UIApplication sharedApplication] openURL:phoneNumber];
telprompt gives the user a choice to place the call or cancel making the call before the phone dials. The two forward slashes after the colon are optional.
well if you are talking about using objective-c to make a phone call on the iphone, then you can do something like this:
NSURL *phoneNumber = [[NSURL alloc] initWithString: #"tel:867-5309"];
[[UIApplication sharedApplication] openURL: phoneNumber];
If you are talking about doing this on a mac ,well, then like others have mentioned that is specific based on number of things like, if you are using voip, a modem, connecting through something like an Asterisks box, etc..
openURL is deprecated.
Now use this:
UIApplication *application = [UIApplication sharedApplication];
[application openURL:[NSURL URLWithString: #"tel:12125551212"] options:#{} completionHandler:nil];
REMOVE EMPTY SPACES IN PHONE NUMBER
NSString *phoneNumberString = #"123 456";
phoneNumberString = [phoneNumberString stringByReplacingOccurrencesOfString:#" " withString:#""];
phoneNumberString = [NSString stringWithFormat#"tel:%#", phoneNumberString];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberString]];
[[UIApplication sharedApplication] openURL:phoneNumberURL];
NSString *phoneNumber = #"Phone number here";
UIWebView *webView = [[UIWebView alloc] init];
NSURL *url = [NSURL URLWithString:numberString];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
webView.dataDetectorTypes = UIDataDetectorTypeNone;
[webView loadRequest:requestURL];
This will either be very platform-specific, or you'll have to use a wrapper library to account for the differences among platforms, so you better state what platform this is intended for. In general, there are various telephony APIs available on most platforms.
On Windows systems there's for example the "TAPI", also things may somewhat differ if you are targeting a digital telephone system such as ISDN, because there are other APIs available.

Resources