Come posso fare telefonata in Objective C?

voti
39

Come posso fare una telefonata in Objective C?

È pubblicato 20/03/2009 alle 12:35
fonte dall'utente
In altre lingue...                            


8 risposte

voti
113

È possibile avviare una chiamata

https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html

Così questo probabilmente funzionerebbe

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]];
Risposto il 20/03/2009 a 12:48
fonte dall'utente

voti
22

Questo è ritagliato da un progetto che ho fatto a fare proprio questo:

NSString *phoneStr = [[NSString alloc] initWithFormat:@"tel:%@",phone_number];
NSURL *phoneURL = [[NSURL alloc] initWithString:phoneStr];
[[UIApplication sharedApplication] openURL:phoneURL];
[phoneURL release];
[phoneStr release];
Risposto il 20/03/2009 a 18:18
fonte dall'utente

voti
17

Può anche essere utile sapere come chiedere all'utente di chiamare un numero:

NSURL *phoneNumber = [NSURL URLWithString:@"telprompt://13232222222"];
[[UIApplication sharedApplication] openURL:phoneNumber];

telpromptdà all'utente una scelta per effettuare la chiamata o annullare effettuare la chiamata prima che il telefono compone. Le due barre dopo i due punti sono opzionali.

Risposto il 29/11/2013 a 20:07
fonte dall'utente

voti
10

bene se si sta parlando con Objective-C per effettuare una chiamata telefonica su iPhone, allora si può fare qualcosa di simile a questo:

NSURL *phoneNumber = [[NSURL alloc] initWithString: @"tel:867-5309"];
[[UIApplication sharedApplication] openURL: phoneNumber];

Se si sta parlando di fare questo su un Mac, beh, allora come altri hanno detto che è specifico in base al numero di cose come, se si utilizza il VoIP, un modem, collegando attraverso qualcosa come una scatola asterischi, ecc ..

Risposto il 20/03/2009 a 12:53
fonte dall'utente

voti
3

Rimuovere gli spazi VUOTI IN NUMERO DI TELEFONO

NSString *phoneNumberString = @"123 456";
phoneNumberString = [phoneNumberString stringByReplacingOccurrencesOfString:@" " withString:@""];
phoneNumberString = [NSString stringWithFormat@"tel:%@", phoneNumberString];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberString]];
[[UIApplication sharedApplication] openURL:phoneNumberURL];
Risposto il 23/09/2015 a 06:12
fonte dall'utente

voti
2

openURL è deprecato.

Ora usare questo:

UIApplication *application = [UIApplication sharedApplication];
[application openURL:[NSURL URLWithString: @"tel:12125551212"] options:@{} completionHandler:nil];
Risposto il 09/06/2017 a 21:30
fonte dall'utente

voti
0
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];
Risposto il 26/05/2015 a 11:45
fonte dall'utente

voti
-1

Tutto questo può essere molto specifico piattaforma, o si dovrà utilizzare una libreria wrapper per spiegare le differenze tra le piattaforme, quindi è stato meglio che piattaforma questo è destinato. In generale, ci sono varie API di telefonia disponibili sulla maggior parte delle piattaforme.

Sui sistemi Windows non c'è ad esempio la "TAPI", anche un po 'le cose possono differiscono se si prendono di mira un sistema telefonico digitale come ISDN, perché ci sono altre API disponibili.

Risposto il 20/03/2009 a 12:48
fonte dall'utente

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more