iPhone Code How to: Call a number from a function or button click

181

Below is the code to call a number within a function.

NSURL *phoneNumberURL = [NSURL URLWithString:@"tel:3053729787"];
[[UIApplication sharedApplication] openURL:phoneNumberURL];

I've tested this call function on both the iphone and ipod. The iphone opens a UIAlert and prompts the user to call or cancel. The ipod ignores the call without causing a crash (same as the simulator)



2 comments ↓

If you found this post useful click the share this button. Contribute below by adding a comment, no registration is required.


  • Kevin says on 09.28.09 at 8:54 am comment #1

    This works fine, but how do you send # and * DTMF tones? These get rejected by this URL scheme.

    And here’s the big question: if the Contacts app can have phone numbers with # and * in them and this works – how can I do that?

  • Ghanshyam das chajjad says on 05.20.10 at 8:03 am comment #2

    mare kai leave nathi karvu.. aa badhu to vahiyaat che.. nakammo che. faltu che… koi na karta aavu

Leave a Comment