【问题标题】:Making a call programmatically from iPhone app and returning back to the app after ending the call从 iPhone 应用程序以编程方式拨打电话并在结束通话后返回应用程序
【发布时间】:2011-10-29 14:41:51
【问题描述】:

我正在尝试从我的 iphone 应用程序发起呼叫,我是通过以下方式进行的..

-(IBAction) call:(id)sender
{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Call Besito" message:@"\n\n\n"
                                                   delegate:self cancelButtonTitle:@"Cancel"  otherButtonTitles:@"Submit", nil];


    [alert show];
    [alert release];
}

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex != [alertView cancelButtonIndex])
    {
      NSString *phone_number = @"0911234567"; // assing dynamically from your code
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString    stringWithFormat:@"tel:%@", phone_number]]]; 
         NSString *phone_number = @"09008934848";
        NSString *phoneStr = [[NSString alloc] initWithFormat:@"tel:%@",phone_number];
        NSURL *phoneURL = [[NSURL alloc] initWithString:phoneStr];
        [[UIApplication sharedApplication] openURL:phoneURL];
        [phoneURL release];
        [phoneStr release];
    }
}

通过上面的代码..我可以成功拨打电话..但是当我结束通话时,我无法返回我的应用程序

所以,我想知道如何实现,那..也请告诉我我们如何使用 webview 发起呼叫...

【问题讨论】:

标签: iphone objective-c ios ios4


【解决方案1】:

这是我的代码:

NSURL *url = [NSURL URLWithString:@"telprompt://123-4567-890"]; 
[[UIApplication  sharedApplication] openURL:url]; 

使用它以便在通话结束后返回应用程序。

【讨论】:

  • welcom,它应该写入的 telprompt 字符串,以便我们可以在通话结束后回到我们的应用程序。
  • 我能知道你都实现了什么吗?
  • 什么意思,如果你特别问我可以告诉我是否这样做。
  • 好的,没关系,其实我也在实现绘图功能,我的代码可以正常工作,但是他们在擦除过程中有点缺陷,请你看看这个链接stackoverflow.com/questions/11502320/…
  • 如果由于余额不足或网络信号导致呼叫失败,是否有办法捕获回调?
【解决方案2】:
UIWebView *callWebview = [[UIWebView alloc] init];
NSURL *telURL = [NSURL URLWithString:@"tel:+9196815*****"];
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];

请试试这个,它一定会让你回到你的应用程序。

【讨论】:

    【解决方案3】:
    NSString *phoneNumber =  // dynamically assigned
    NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
    NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
    [[UIApplication sharedApplication] openURL:phoneURL];
    

    【讨论】:

      【解决方案4】:

      以下代码将不会返回到您的应用[在拨打电话之前不会显示警报视图]

      UIWebView *callWebview = [[UIWebView alloc] init];
      NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phoneNumber]];
      [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
      

      以下代码将返回到您的应用“alertview will show before make call”

      UIWebView *callWebview = [[UIWebView alloc] init];
      NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", phoneNumber]];
      [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
      

      【讨论】:

        【解决方案5】:

        你也可以使用 webview,这是我的代码:

        NSURL *url = [NSURL URLWithString:@"tel://123-4567-890"];
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(50, 50, 150, 100)];
        [self.view addSubview:btn];
        UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(50, 50, 150, 100)];
        webview.alpha = 0.0;        
        [webview loadRequest:[NSURLRequest requestWithURL:url]];
        // Assume we are in a view controller and have access to self.view
        [self.view insertSubview:webview belowSubview:btn];
        [webview release];
        [btn release];
        

        【讨论】:

          【解决方案6】:

          结束通话后无法返回应用,因为它是应用。

          【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2019-09-24
          • 2010-10-21
          • 2011-03-09
          • 1970-01-01
          • 1970-01-01
          • 2012-04-01
          • 1970-01-01
          相关资源
          最近更新 更多