iOS call, text messaging feature

Source: Internet
Author: User

First of all:

To introduce messageui.framework in frameworks

#import <MessageUI/MessageUI.h>
Add protocol:<mfmessagecomposeviewcontrollerdelegate>

Then look at the code:

There are two types of SMS call, 1 is the call system within the SMS function, you can send a text message back to the app, another call system outside the text messaging function, can not recall the app

Call the SMS function within the system to return to the app
if ([Mfmessagecomposeviewcontroller Cansendtext]) {

Mfmessagecomposeviewcontroller *picker =
[[Mfmessagecomposeviewcontroller alloc] init];
Picker.messagecomposedelegate = self;
Picker.navigationBar.tintColor = [Uicolor blackcolor];
Default recipients (can be multiple)
picker.recipients = [Nsarray arraywithobject:@ "", @ ""];
Picker.body = @ "AAAAAAAAAA";

[Self Presentviewcontroller:picker
Animated:yes
completion:^{

}];
}else{
Call the SMS function outside the system, can not return to the app
[[UIApplication Sharedapplication]openurl:[nsurl urlwithstring:[nsstring stringwithformat:@ "sms://%@", Mobile]];
}

}

#pragma mark-mfmessagecomposeviewcontrollerdelegate

-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: ( Messagecomposeresult) Result
{
Switch (Result) {
Case messagecomposeresultcancelled:
ShowMsg (@ "send Cancel");
Break
Case Messagecomposeresultsent:
ShowMsg (@ "send success");
Break
Case messagecomposeresultfailed:
ShowMsg (@ "send failed");
Break
Default
Break
}

[Controller Dismissviewcontrolleranimated:no completion:^{

}];
}

Large arc function

nsstring* DeviceType = [Uidevice currentdevice].model;
return [DeviceType isequaltostring:@ "IPhone"];

if (![ Method isphonesupported]) {
ShowMsg (@ "Current device does not support phone calls");
return NO;
}

Nsurl *telurl =[nsurl urlwithstring:[nsstring stringwithformat:@ "tel://%@", Num]];
[[UIApplication sharedapplication] openurl:telurl];



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

iOS call, text messaging feature

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.