¿Cómo puedo hacer una llamada telefónica en Objective C?
¿Cómo puedo hacer una llamada telefónica en Objective C?
Puedes iniciar una llamada
Entonces esto probablemente funcionaría
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]];
Esto está recortado de un proyecto que hice para hacer justamente eso:
NSString *phoneStr = [[NSString alloc] initWithFormat:@"tel:%@",phone_number];
NSURL *phoneURL = [[NSURL alloc] initWithString:phoneStr];
[[UIApplication sharedApplication] openURL:phoneURL];
[phoneURL release];
[phoneStr release];
También puede ser útil saber cómo solicitar al usuario que llame a un número:
NSURL *phoneNumber = [NSURL URLWithString:@"telprompt://13232222222"];
[[UIApplication sharedApplication] openURL:phoneNumber];
telpromptda al usuario una opción para realizar la llamada o cancelar la realización de la llamada antes de que el teléfono marca. Las dos barras diagonales después de los dos puntos son opcionales.
fuente por usuario Mieczysław Daniel Dyba
Bueno, si estás hablando sobre el uso de Object-C para hacer una llamada telefónica en el iPhone, entonces puedes hacer algo como esto:
NSURL *phoneNumber = [[NSURL alloc] initWithString: @"tel:867-5309"];
[[UIApplication sharedApplication] openURL: phoneNumber];
Si estás hablando de hacer esto en un Mac, bueno, como otros han mencionado, es específico en función de varias cosas como, si estás usando VoIP, un módem, conectando a través de algo así como un cuadro de Asteriscos, etc.
Quitar espacios VACÍOS EN NÚMERO DE TELÉFONO
NSString *phoneNumberString = @"123 456";
phoneNumberString = [phoneNumberString stringByReplacingOccurrencesOfString:@" " withString:@""];
phoneNumberString = [NSString stringWithFormat@"tel:%@", phoneNumberString];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberString]];
[[UIApplication sharedApplication] openURL:phoneNumberURL];
openURL está en desuso.
Ahora usa la siguiente:
UIApplication *application = [UIApplication sharedApplication];
[application openURL:[NSURL URLWithString: @"tel:12125551212"] options:@{} completionHandler:nil];
NSString *phoneNumber = @"Phone number here";
UIWebView *webView = [[UIWebView alloc] init];
NSURL *url = [NSURL URLWithString:numberString];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
webView.dataDetectorTypes = UIDataDetectorTypeNone;
[webView loadRequest:requestURL];
Esto será muy específico de la plataforma, o tendrá que usar una biblioteca contenedora para tener en cuenta las diferencias entre las plataformas, por lo que es mejor indicar a qué plataforma está destinada. En general, hay varias API de telefonía disponibles en la mayoría de las plataformas.
En los sistemas Windows existe, por ejemplo, el "TAPI", también pueden diferir en algo si se dirige a un sistema telefónico digital como ISDN, porque hay otras API disponibles.













