Summary:
Within the application, the function of the system is called to make calls, text messages and emails, and directly jump to the functional interface of the system by phone number or mailbox.
PS: Debugging as if only the real machine debugging, the simulator does not respond, the real machine can jump, do not know whether it must be real machine, but the method is certainly feasible.
1. Call
There are two ways in which the in-app call system calls:
1) WebView mode
Use WebView to jump, the phone number through the URL to WebView, this way will pop up whether to dial the prompt, you can choose to call or not dial, finish will automatically return to the application interface, recommended .
UIWebView *callwebview =[[uiwebview alloc] init]; Nsurl *telurl =[nsurl urlwithstring:[nsstring stringwithformat:@ "tel:%@", Self.phoneNumber.text]]; [Callwebview loadrequest:[nsurlrequest Requestwithurl:telurl]; [Self.view Addsubview:callwebview];
InAdd "Tel:" At the beginning of the URL, followed by the phone number, the system will be recognized as the call dialer.
2) uiapplication mode
Use UIApplication to jump, the same pass and the same URL in the same way, this way will not pop up a hint to ask you to confirm the call or not, but directly dial, play will also stop in the address book that, will not go back to the application, not recommended.
Nsurl *telurl =[nsurl urlwithstring:[nsstring stringwithformat:@ "tel:%@", Self.phoneNumber.text]]; [[UIApplication sharedapplication] openurl:telurl];
2. Send SMS
In-app call system to send text messages also have two ways, and phone is the same, the only difference is the URL to "SMS:" to start , so you can tell the system to call the text messaging function:
1) WebView mode
Use WebView to jump, the phone number through the URL to WebView, this way will jump to the SMS interface sent, recommended .
UIWebView *smswebview =[[uiwebview alloc] init]; Nsurl *telurl =[nsurl urlwithstring:[nsstring stringwithformat:@ "sms:%@", Self.phoneNumber.text]]; [Smswebview loadrequest:[nsurlrequest Requestwithurl:telurl]; [Self.view Addsubview:smswebview];
2) uiapplication mode
Use UIApplication to jump, this way will be sent directly in the background, not recommended.
Nsurl *telurl =[nsurl urlwithstring:[nsstring stringwithformat:@ "sms:%@", Self.phoneNumber.text]]; [[UIApplication sharedapplication] openurl:telurl];
3. Send mail
e-mail or the same way to use WebView, with the phone, text messages are the same, to change the URL to "mailto:" The beginning , followed by email address:
UIWebView *emailwebview =[[uiwebview alloc] init]; Nsurl *emailurl =[nsurl urlwithstring:[nsstring stringwithformat:@ "mailto:%@", Self.email.text]]; [Emailwebview loadrequest:[nsurlrequest Requestwithurl:emailurl]; [Self.view Addsubview:emailwebview];
This jumps to the mailbox app that comes with the system.
When you use these features, you should be aware that regular expressions detect mobile phone numbers, mailbox formats, and so on.
Here you can download my sample project: Https://github.com/Cloudox/TelTest
Reprint please indicate the source, thank you
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
iOS app call system call, text message and email function