In iOS 4.0 and later, you can send text messages from within your application. This feature is strictly for sending messages. Incoming SMS messages go to the built-in Messages app.

To use the SMS composition interface, you must add MessageUI.framework to your Xcode project and link against it in any relevant targets. To access the classes and headers of the framework, include an #import <MessageUI/MessageUI.h> statement at the top of any relevant source files. For information on how to add frameworks to your project, see “Files in Projects” in Xcode Project Management Guide.

To provide the standard user interface for composing an SMS (Short Message Service) message, use the <a href="" target="_self">MFMessageComposeViewController</a> class. Create an instance of this class and assign it a delegate object. The delegate must conform to the <a href="" target="_self">MFMessageComposeViewControllerDelegate</a>protocol.

Before presenting the composition interface to the user, you can configure initial recipients and message content. With setup complete, call the UIViewController <a href="" target="_self">presentModalViewController:animated:</a> method to present the SMS message composition view controller modally.

While the interface is visible, the user can edit the recipients list and message content. The user then sends the message, or cancels it, by tapping the appropriate control in the interface.

If the user requests that the message be sent, the system queues it for delivery and invokes the delegate object’s <a href="" target="_self">messageComposeViewController:didFinishWithResult:</a> method. The result is one of “sent,” “cancelled,” or “failed.”

Finally, the delegate is responsible for dismissing the message composition view controller, which it should do by calling the UIViewController <a href="" target="_self">dismissModalViewControllerAnimated:</a> method.

For a complete description of the <a href="" target="_self">MFMessageComposeViewController</a> class, see MFMessageComposeViewController Class Reference.

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注