Выполнение вызова программно из приложения iPhone и возврат к нему после завершения вызова - PullRequest
8 голосов
/ 18 августа 2011

Я пытаюсь инициировать вызов из моего приложения для 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];
    }
}

по указанному выше коду .. Я могу успешно позвонить ... но когда я заканчиваю звонок, я не могу вернуться в свое приложение

Итак, я хочу знать, как этого добиться, также ... пожалуйста, скажите мне, как мы можем инициировать вызов с помощью веб-просмотра ...

Ответы [ 7 ]

18 голосов
/ 18 июля 2012

Это мой код:

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

Используйте его, чтобы после завершения вызова он возвращался в приложение.

1 голос
/ 06 сентября 2013
UIWebView *callWebview = [[UIWebView alloc] init];
NSURL *telURL = [NSURL URLWithString:@"tel:+9196815*****"];
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];

Пожалуйста, попробуйте это, это определенно позволит вам вернуться к вашему приложению.

0 голосов
/ 30 декабря 2014
NSString *phoneNumber =  // dynamically assigned
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
[[UIApplication sharedApplication] openURL:phoneURL];
0 голосов
/ 03 февраля 2014

следующий код не вернется в ваше приложение [оповещение не будет отображаться до вызова)] 1001 *

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

следующий код вернется в ваше приложение

0 голосов
/ 14 июня 2013

Пожалуйста, посмотрите на приложение OneTap. Это свободно Он так и сделал.

0 голосов
/ 18 июля 2012

Вы также можете использовать веб-просмотр, это мой код:

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];
0 голосов
/ 18 августа 2011

Невозможно вернуться в приложение после завершения вызова, потому что это приложение.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...