Mfmessagecomposeviewcontroller is also a category in the Messageui Framework, and its main function is to make the relevant format of the SMS message, which is used in the same way as Mfmailcomposeviewcontroller, you can also add SMS messages to your app through a few simple settings.
When using the MESSAGEUI framework first, and referencing its header file, the Xcode 4 framework import method can refer to
Xcode 4 Adds a new Framework approach to this article.
#import <MessageUI/MessageUI.h>
Then set the <MFMessageComposeViewControllerDelegate> agent on the category where you want to use this object.
Then it is the program code that is actually delivering the SMS message.
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
Determine if the device is in the state of the transmitted message
if ([Mfmessagecomposeviewcontroller Cansendtext]) {
Set SMS message Content
Controller.body = @ "How are you?" ";
Set the number of the Transfer object
controller.recipients = [Nsarray arraywithobjects:@ "0912345678", nil];
Set up Proxy
Controller.messagecomposedelegate = self;
//显示controller的画面
[self presentModalViewController:controller animated:YES];
}
As for the message after it is transmitted, it triggers the following intrinsic function, and can be used to determine whether the message was delivered successfully or was canceled by the user by the parameters of the function.
//使用者完成操作时所呼叫的内部函数
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
Switch (Result) {
Case Messagecomposeresultsent:
Message delivered successfully
Break
Case messagecomposeresultfailed:
Message Delivery failed
Break
Case messagecomposeresultcancelled:
Message canceled by user
Break
default:
break;
}
}
PS: About the use of Mfmailcomposeviewcontroller can refer to
The basic use of Mfmailcomposeviewcontroller is a text.
IOS Mfmessagecomposeviewcontroller Texting feature