iOS 4.2 – 通话后返回到应用程序

我可以使用以下方法在我的应用程序中成功启动一个电话:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]]; 

但是,一旦电话被终止,是否有可能自动返回到应用程序? 看来这是不可能在iPhone OS 3.0下,但我希望现在可以在iOS 4.2下多任务(我无法find任何特定于iOS 4.2的问题上的任何信息)。

在此先感谢您的帮助!

据我所知,因为控制传递给phone.app来打电话,一旦呼叫结束,就iOS而言,phone.app是当前的应用程序,所以留在前台。

目前似乎没有什么可以做的。 这可能是值得放入一个function请求,以允许类似于MFMessageComposer “模式电话”,允许您发送电子邮件/短信在您自己的应用程序。

编辑

您可以按照Frin在下面的答案给出的build议,因为这包含更多的最新信息。

我知道这个问题是非常古老的,但目前你可以通过使用telprompt://来完成这个工作(至less在iOS 5上),比如:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://123456789"]]; 

iPhone将显示警报视图确认,当通话结束时,您的应用程序再次显示,而不是iPhone的通话应用程序。

我相信问题是你仍然在进行sharedApplication调用,并且按照其他线程,不需要将Web视图添加为层次结构的一部分。

我把你的代码,修改如下,它工作得很好:

 NSString *phoneStr = [NSString stringWithFormat:@"tel:%@", phoneNumber]; NSURL *phoneURL = [[NSURL alloc] initWithString:phoneStr]; // The WebView needs to be retained otherwise it won't work. if (!mCallWebview) mCallWebview = [[UIWebView alloc] init]; [mCallWebview loadRequest:[NSURLRequest requestWithURL:phoneURL]]; 

在调用之后,您自己的应用程序像以前一样运行

这是从iOS 4.0引入以来最有可能的。 处理这个问题的最佳方法是使用UIWebView,在WebView中加载“tel:0123456”URL,而不将其添加到视图层次结构中。 iOS会自动显示电话号码的提醒,并要求用户按“通话”进行确认。

一旦通话完成,您的应用程序将自动回到前台。 在其他线程中详细说明: 在本机代码中调用不同于UIWebView的电话后,返回到应用程序行为

我已经在iPhone SDK中给出了这个答案:通话结束后启动应用程序我也会在这里发布我的代码..在这里你可以打电话,而不closures你的应用程序..

 -(IBAction) dialNumber:(id)sender{ NSString *aPhoneNo = [@"tel://" stringByAppendingString:[itsPhoneNoArray objectAtIndex:[sender tag]]] ; NSURL *url= [NSURL URLWithString:aPhoneNo]; NSURL *url= [NSURL URLWithString:aPhoneNo]; NSString *osVersion = [[UIDevice currentDevice] systemVersion]; if ([osVersion floatValue] >= 3.1) { UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; [webview loadRequest:[NSURLRequest requestWithURL:url]]; webview.hidden = YES; // Assume we are in a view controller and have access to self.view [self.view addSubview:webview]; [webview release]; } else { // On 3.0 and below, dial as usual [[UIApplication sharedApplication] openURL: url]; } } 

在iOS 9.3.4中,我尝试的每种技术都可以在通话后返回到通话应用程序。 这种行为最近是否改变了? 这个例子只是一个Swift和https://github.com/jatraiz/RZTelpromptExample的简化版本:

 class ViewController: UIViewController { let phoneNumber = "7204790465" override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } @IBAction func callWithTelPushed(sender: AnyObject) { if let url = NSURL(string: "tel:" + self.phoneNumber) { UIApplication.sharedApplication().openURL(url) } } @IBAction func callWithTelpromptPushed(sender: AnyObject) { if let url = NSURL(string: "telprompt:" + self.phoneNumber) { UIApplication.sharedApplication().openURL(url) } } @IBAction func callWithRZTelpromptPushed(sender: AnyObject) { RZTelprompt.callWithString(self.phoneNumber) } }