2011-08-18 69 views
8

我试图启动从我的iPhone应用程序的调用返回后,返回到应用程序,我做到了follwing方式..从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发起呼叫...

谢谢& Registers Ranjit

+0

这个问题详细解答你的问题。只需使用uiwebview来调用,而不是openURL:http://stackoverflow.com/questions/5317783/return-to-app-behavior-after-phone-call-different-in-native-code-than-uiwebview –

回答

17

这是我的代码:

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

使用此,使通话结束后,将返回到应用程序。

+0

嗨桑德亚,感谢乌拉圭回合的答复,这是什么“telpromt? – Ranjit

+0

的开山鼻祖,其telprompt字符串应该写这样我们就可以通话结束后,我们回到我们的应用程序。 –

+0

啊,我的应用没...... –

-4

在结束通话后无法返回到应用程序,因为它是一个应用程序。

+0

hi lokus,但许多人说它可能通过使用webview ..打个电话 – Ranjit

+0

你是在说这个帖子http://stackoverflow.com/questions/3145418/placing-a-call-programmatically-on-iphone-and-返回到同一个应用程序后挂断? – Lokus001

+0

雅,,, lokus和拉索这个http://stackoverflow.com/questions/5317783/return-to-app-behavior-after-phone-call-different-in-native-code-than-uiwebview – Ranjit

-1

您也可以使用web视图,这是我的代码:

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]; 
-3

请大家看看OneTap应用。它是免费的 它就是这样做的。

+0

这不是问题的答案 – Mutawe

1
UIWebView *callWebview = [[UIWebView alloc] init]; 
NSURL *telURL = [NSURL URLWithString:@"tel:+9196815*****"]; 
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 

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

0

下面的代码将不会返回到你的应用程序[无alertview将发出呼叫之前显示]

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

下面的代码将返回到您的应用程序

UIWebView *callWebview = [[UIWebView alloc] init]; 
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", phoneNumber]]; 
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 
0
NSString *phoneNumber = // dynamically assigned 
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber]; 
NSURL *phoneURL = [NSURL URLWithString:phoneURLString]; 
[[UIApplication sharedApplication] openURL:phoneURL]; 
“alertview发出呼叫之前将显示”