IOS Mfmessagecomposeviewcontroller Texting feature

Source: Internet
Author: User

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

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.