iOS Development call call, send SMS

Source: Internet
Author: User

1. Call to bring your own mail
[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:@ "Mailto://[email protected]"];

2. Call Telephone Phone
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "tel://8008808888"];
Back to app after you call in iOS app
The usual way to call in the app is:
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "tel://123456789"];

When you make a call this way, the iphone interface stays on the phone interface when the user ends the call.
This allows users to automatically return to the app after the call is completed:
Uiwebview*callwebview =[[uiwebview alloc] init];
Nsurl *telurl =[nsurl urlwithstring:@ "tel:10086"];//looks like tel://or Tel: All right
[Callwebview loadrequest:[nsurlrequest Requestwithurl:telurl];
Remember to add to the view
[Self.view Addsubview:callwebview];

There is also a private method: (may not be audited)
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "telprompt://10086"];

3. Call SMS
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "sms://800888"];

4. Call your own browser safari
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "http://www.hzlzh.com"];

Call phone can pass number, call SMS can only set number, cannot initialize SMS content.

If you need to pass content, you can do the following:
Join: 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];

}

}

Processing the results of a response sent out
-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: ( Messagecomposeresult) Result
{
[Self dismissmodalviewcontrolleranimated:yes];

if (result = = messagecomposeresultcancelled)
NSLog (@ "Message cancelled")
else if (result = = Messagecomposeresultsent)
NSLog (@ "Message sent")
Else
NSLog (@ "Message failed")
}

The default text messaging interface is in English, the solution is:
Add a group of Chinese to the localization in. xib It's OK.

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.