iOS Issue summary: 2015-1-9 iOS call system texting and calling function

Source: Internet
Author: User

IOS call system texting and calling function

iOS phone Smsinterface Internet class
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;  }  

}

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:@"我在爱折客上看到:%@ 可能对你有用,推荐给你!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

}

}

iOS Issue summary: 2015-1-9 iOS call system texting and calling function

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.