How do I make telephone numbers in iPhone clickable? - ios

I have some telephone numbers in UILabel in various cells of a UITableView.
I also have telephone numbers in the subtitle of MKAnnotations in my MapViews.
How I can make these telephone numbers clickable so that they launch the phone app on the iPhone and dial the number?

Only UITextView handles this automatically.
Anything else will require you to make the call yourself (by responding to a tap, for instance):
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:15415551234"]];

Related

iOS - Is it possible to make a phone call programmatically without showing the phone number?

I know we can make a phone call programmatically on iOS, and it opens the phone app and display the phone number. Is there a way to hide the phone number or show something else instead of the phone number?
Thanks.
You could make a contact for it so it shows the name of the contact name instead of the phone number, but there is no possible way to actually hide the phone number the user is calling.
You can not display name programatically when calling, because iOS does not provide you any mechanism in which you can pass name with phone number. The only way is you have to first save phone number with your desired name as a contact into user's phone and after that make a call programatically.

How do I control the notification counter for my home screen app icon? [duplicate]

This question already has an answer here:
How do I use the numeric notification "bubble" in iOS?
(1 answer)
Closed 7 years ago.
When one first turns on one's iPhone, one is presented with this screen that lists all the apps installed in that phone. Some of them might have little red circles with white numbers in them that represent unread notifications from that app. Now I'm making an iOS app, and I want to trigger the appearance of white numbers in red circles like this. How do I do that?
Just use:
[[UIApplication sharedApplication] applicationIconBadgeNumber:numberDesired];
Sets the number currently set as the badge of the app icon in Springboard.
Set to 0 (zero) to hide the badge number. The default value of this property is 0.

How to jump to dial pad in iOS

To make a phone call, use [[UIApplication sharedApplication] openURL:#"tel://"] it's very easy.
The problem is: I don't want to dial immediately, I need when user taps the 'call' button, app jumps to dial pad in phone app, and displays specific phone number, user can press 'Call' button to make this phone call.
Anybody know how can I achieve this?
Appreciate!
iPhone SDK not allows you to dial a number from the application. But you can do it by using a UITextField. Set keyboard type to UIKeyboardTypePhonePad
textfield.keyboardType = UIKeyboardTypePhonePad;
and set that number to textfield,
textfield.text = numberToDial;
and then call the following line when user taps on your call button
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel://%#",textfield.text]]];

Directly launch phoneNumber dialog on iPad

If I use the UIDataDetectorTypePhoneNumber on a UITextView, and click a phone number on a device that has no phone (e.g. iPad), I get a Send Message / Add to Contacts / Copy popover. Is there some way to bring up that dialog directly in code or would I have to reimplement?
I did try [[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:5555555"]]; but that does not bring up the dialog.
There are some subtle differences between how detected links and buttons behave and my client wants a clickable phone number that behaves like a button.
I did some method swizzling to see where this popover comes from, and it looks like it is generated before the openURL: method in UIApplication.
Digging further, it looks like the popover comes from some private objects in UITextView.
I think you'll have to reimplement.
Did you try it with some forward slashes?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://5555555"]];
Possibly related to this.
Use telprompt://5555555 instead of tel:5555555

opening dial pad for calling number user want

i want to open dial pad when user click on call button and then user enter phone number and call it
i know we can make call like this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"telprompt://2135554321"]];
but i want to open dial pad and then let user enter number and press call button to call
if this is not possible then want to do something like my app open direct to dail pad then user call it and then it should redirect to my app
No you cant do this in iOS . iPhone SDK not gives you direct access to dial a numbers from the application .The one way to achieve this is
take a text field
textfield.keyboardType = UIKeyboardTypePhonePad;
and
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel://%#",textfield.text]]];
You have to see the format for entering the number.
Why not create a UIView that has a "UITextField" and when the text field comes up, have the keyboard set to only be numbers (i.e. pretty much the same thing as the dialpad).
And once they are done entering in the number, then you can call the "openURL" line you have above.

Resources