简体   繁体   中英

iPhone dev - How can I call a phone number from within an app? Also, how can I hang-up from within the app?

Those are the two basic questions. First of all, I need to know if it's even possible to programmatically hang-up the phone from within my app (when the user presses a button, for instance). Also, is it possible to make a call from within my app, without having to leave my app? As in, the user can talk on the phone, but still see my app front and center the whole time?

Thanks

No to both questions*: it's not possible, unless you go to the dark side (jailbreak).

To know what kind of options are available to developers in regard to the phone functionality, take a look at Core Telephony's documentation .

  • You can pass a phone call by passing a url of the type tel://%@ to [[UIApplication sharedApplication] openURL:url] but you can't "stay" in the App itself (phone.app will take care of the phone call).

When you programmatically make a phone call, your app jumps into the phone app.

You can make a phone call like this:

NSURL *url = [[[NSURL alloc] initWithString:[NSString stringWithFormat:@"tel://%@", kSavedNumber]] autorelease];            
[[UIApplication sharedApplication] openURL:url]

Once you do this, the user will not be in your app, and they will be hanging up using the standard phone interface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM