IOS developers call, send text messages, and open websites

Source: Internet
Author: User

1. Call built-in mail
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "mailto: // admin@hzlzh.com"];

2. Call phone
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "tel: // 8008808888"];
The iOS app returns to the app after the call ends.
Generally, you can call the following method in an application:
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "tel: // 123456789"];

When you call a phone in this way, the iphone interface will stay on the phone interface after the user finishes the call.
The following method can be used to automatically return to the application after the user finishes the call:
UIWebView * callWebview = [[UIWebView alloc] init];
NSURL * telURL = [NSURL URLWithString: @ "tel: 10086"]; // It Looks Like tel: // or tel:
[CallWebview loadRequest: [NSURLRequest requestWithURL: telURL];
// Remember to add to view
[Self. view addSubview: callWebview];

There is also a private method: (may not pass the Review)
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "telprompt: // 10086"];

3. Call SMS
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "sms: // 800888"];

4. Call the self-contained browser safari
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "http://www.hzlzh.com"];

You can call phone to pass the number. You can call SMS to set only the number and Cannot initialize the SMS content.

To transfer the content, you can do the following:
Add: MessageUI. framework

# Import <MessageUI/MFMessageComposeViewController. h>

Implement Proxy: MFMessageComposeViewControllerDelegate

 

Call the sendSMS Function
// Content, Recipient List
-(Void) sendSMS :( NSString *) bodyOfMessage recipientList :( NSArray *) recipients
{

MFMessageComposeViewController * controller = [[[MFMessageComposeViewController alloc] init] autorelease];

If ([MFMessageComposeViewController canSendText])

{

Controller. body = bodyOfMessage;

Controller. recipients = recipients;

Controller. messageComposeDelegate = self;

[Self presentModalViewController: controller animated: YES];

}

}

// Process the sent response results
-(Void) messageComposeViewController :( MFMessageComposeViewController *) controller didFinishWithResult :( MessageComposeResult) result
{
[Self dismissModalViewControllerAnimated: YES];
 
If (result = MessageComposeResultCancelled)
NSLog (@ "Message canceled ")
Else if (result = MessageComposeResultSent)
NSLog (@ "Message sent ")
Else
NSLog (@ "Message failed ")
}
 
The default text message sending interface is in English. solution:
Add a chinese group to Localization in. xib.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.