2011-08-18 93 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發出呼叫之前將顯示」