Using Dialer for iOS app [duplicate] - iphone

I allow my user to select phone numbers in my application. How can I then bring up the iPhone call screen and then if possible, initiate the phone call?

You'll have to recreate the dial screen within your application (didn't take too long for me to do.) Once you have the phone number entered, you'll need to initiate the phone call by doing:
NSString* theNumberYouGathered = #"9994441234";
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: [NSString stringWithFormatting: #"tel:%s", theNumberYouGathered]]];
Note this will only work on the actual phone, and not the simulator.
To create the dialer screen you'll need to:
Create a xib file with a set of UIButtons (for #s 1-9), a UILabel to show the currently entered number, and a "Call" button.
Hook up the presses on the number UIButtons and add the digit to a local variable NSString on your ViewController. Update the UILabel with this number.
When the call UIButton is pressed, take the locally stored # and place the aforementioned method call with it.

You can do this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:12125551212"]];
which will create a UIAlertView prompting the user to call the number or cancel.

You can use below code
NSString *phoneNumber = #"18000275749"; // dynamically assigned
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"telprompt://%#",phoneNumber]]];

Related

Is there a way do edit alert that pops up before making a call?

In my application I implemented calling a number programmatically using following code:
NSString *phoneNumber = [#"telprompt://" stringByAppendingString:#"180"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
When I press the button which triggers this method, the alert appears on screen. The alert wants you to confirm the call so you are aware of the number you are calling.
In the alert label there is written just number. But I want to edit it so it will show something more human like "Do you want to call 180?"

Make a Call from UITableViewCell

I stuck with a problem.
In my tableView I got a cell with a phone number. I would like to click on the phone number and make a call.
I implemented the following in didSelectRowAtIndexPath:
NSString *cifra=#"tel://123456789";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:cifra]];
NSLog(#"after call %#",cifra);
Unfortunatly it doesnt do anything. In my log it shows me my "after call ... " but it is not calling. No error, no log, no action :(
It works for me with opening a website or googleMaps, but not for calling.
Is there anything i can do?
Maybe a it is simple answer, but i really dont know what to do. Is there a different way to make a call?
I am using the iPhone Simulator. Is this the problem? But it should do a thing, shouldn't it? :)
Thanks for your help!
You can't make calls from the Simulator.
If you want to test making a phone call, run the app on your device, then press the cell to make a phone call on your actual device.
You can simulate the in-call status bar, but there is nothing actually happening when it comes to actual phone calls.
Hardware > Toggle In-Call Status Bar
Note that using [[UIApplication sharedApplication] openURL:SOMEPHONENUMBER]; does not trigger this event.
Tried this code to make a call
NSString *prefix = (#"tel://(972)818-32432");
UIApplication *app = [UIApplication sharedApplication];
NSString *dialThis = [NSString stringWithFormat:#"%#", prefix];
NSURL *url = [NSURL URLWithString:dialThis];
[app openURL:url];
On top of the answers mentioning you can't make calls from the simulator, cifra should be #"tel:123456789", the double slashes aren't needed.

UIButton does not perform phone call

Seems like this should be simple enough but for whatever reason I am unable to get the phone feature to prompt when my UIButton is pressed.
-(IBAction)viewMapButton:(id) sender
{
NSString *phoneNumber = [[NSString alloc] initWithString:#"tel:1234567890"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
NSLog(#"Call");
}
My NSLog is successfully called. I am running this just on the iOS simulator; is that causing it not to prompt to place the call?
Thanks!
Flea
The iOS simulator doesn't have a phone (just like the iPod Touch), so nothing will happen when you call the tel URL scheme.

how do i launch the iphone sms text application in objective-c via the sms: url scheme?

I have a button in my obj-c application that I would like to launch the iphone text application when a button is pressed.
i've looked at the solution here How to use iPhone Custom URL schemes and have attached an action to my button (via the 'touch up inside' event), but the text app doesn't launch when the button is pressed.
here is my code
(IBAction)sendMsgBtnPressed:(id)sender {
NSLog(#"sendMsgBtnPressed");
NSString *stringURL = #"sms:+14155551212";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
[stringURL release];
}
i know this is being called because i can see the NSLog() output in my console. When I use a http:// scheme it works fine & launches Safari but sms: does not appear to work. Any idea what I am missing here?
Try removing the leading plus sign before the numbers in your url. The plus sign is used for international numbers and you can safely replace it with two leading zeroes. Moreover, be sure to provide a string in which no space occurs between numbers: something like
NSString *stringURL = #"sms:00141555 51212"; will NOT work correctly.
One more thing. The statement
[stringURL release];
is not correct because stringURL has not being retained. You should remove it from your method.
Notice that the SMS application will be opened ONLY in iPhone device - not simulator and not iPod Touch.
The SMS application doesn't exist on simulator and iPod Touch...
You can also check if the device can invoke the SMS app with
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:stringURL]]

Phone call using a number in a UITextField

How can I make a phone call in my app to a number that's been input to a UITextField?
You should be able to call openURL: or openURL:options:completionHandler: with a "tel:" protocol. See the Phone Links section of the protocol reference. In iOS 3.x you will see a prompt though in iOS 2.x it will just dial.
NSString *callTextFiel = [NSString StringWithFormat:#"tel:%#", textField.text];
[[UIApplication SharedApplication] openURL:[NSURL URLWithString:callTextField]];