IOS call system texting and calling function

Source: Internet
Author: User

IOS call system texting and calling function

http://blog.csdn.net/lwq421336220/article/details/7818979

Let's start by introducing one of the simplest methods:

Call Call function

[[uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "tel://10086"];

Call to send SMS function

[[UIApplication sharedapplication]openurl:[nsurl urlwithstring:@ "sms://10000"];

The above text messaging function is to call the system interface, the following is a click to implement a button to send text messages directly, equivalent to send the background, can be on the software store, not sure. Relative recommendations, try to use the first one.

First import mfmessagecomposeviewcontrollerdelegate This agent, implement the method inside

-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) Controllerdidfinishwithresult: ( Messagecomposeresult) Result {

Notifies users about errors associated with the interface

Switch (Result) {

Case messagecomposeresultcancelled:

if (DEBUG) NSLog (@ "result:canceled");

Break

Case Messagecomposeresultsent:

if (DEBUG) NSLog (@ "result:sent");

Break

Case messagecomposeresultfailed:

if (DEBUG) NSLog (@ "result:failed");

Break

Default

Break

}

[Self dismissmodalviewcontrolleranimated:yes];

}

Mass SMS:

-(ibaction) sendsms {

BOOL cansendsms = [Mfmessagecomposeviewcontroller cansendtext];

NSLog (@ "Can send SMS [%d]", cansendsms);

if (cansendsms) {

Mfmessagecomposeviewcontroller *picker = [[Mfmessagecomposeviewcontroller alloc] init];

Picker.messagecomposedelegate = self;

Picker.navigationBar.tintColor = [Uicolor blackcolor];

Picker.body = @ "Test";

picker.recipients = [Nsarray arraywithobject:@ "10086"];

[Self presentmodalviewcontroller:picker animated:yes];

[Picker release];

}

}

Send a text message to a person:

Get content from a Web page

-(void) Displaysmscomposersheet

{

Mfmessagecomposeviewcontroller *picker = [[Mfmessagecomposeviewcontroller alloc] init];

Picker.messagecomposedelegate = self;

UIWebView *web = nil;

nsmutablestring* Absurl = [[Nsmutablestring alloc] initWithString:web.request.URL.absoluteString];

[Absurl replaceoccurrencesofstring:@ "http://i.aizheke.com" withstring:@ "http://m.aizheke.com" options: Nscaseinsensitivesearch range:nsmakerange (0, [absurl length])];

Picker.body=[nsstring stringwithformat:@ "I see in the Love Fold guest:%@ may be useful to you, recommend to you!" link:%@ ", [webstringbyevaluatingjavascriptfromstring:@" Document.title "],absurl];

[Absurl release];

[Self presentmodalviewcontroller:picker animated:yes];

[Picker release];

}

Event binding Send SMS

-(Ibaction) Showsmspicker: (ID) Sender {

Class MessageClass = (nsclassfromstring (@ "Mfmessagecomposeviewcontroller"));

if (MessageClass! = nil) {

if ([MessageClass Cansendtext]) {

[Self displaysmscomposersheet];

}

else {

Device does not have SMS function

}

}

else {

iOS version is too low for iOS4.0 to send SMS within the program

}

}

the above content is a part of the various sites, I add their own understanding, collation, as for the Internet from the part of the author is who, from where, I do not know now, write out for everyone to learn. If you are the author of that part, please contact me!

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.