iOS Developer Library

Developer

MessageUI Framework Reference MFMessageComposeViewControllerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

MFMessageComposeViewControllerDelegate

Inheritance


Not Applicable

Import Statement


Swift

import MessageUI

Objective-C

@import MessageUI;

Availability


Available in iOS 4.0 and later.

The MFMessageComposeViewControllerDelegate protocol defines a single method that custom objects can implement to respond to updates from a message composition view (an instance of the MFMessageComposeViewController class). Use the method of this protocol to respond to the end of the user composing an SMS message. The method includes information about whether the user chose to send or cancel the message or whether the attempt to send it failed.

  • Tells the delegate that the user finished composing the message. (required)

    Declaration

    Swift

    func messageComposeViewController(_ controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult)

    Objective-C

    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result

    Parameters

    controller

    The message composition view controller that is returning the result.

    result

    A result code indicating how the user chose to complete the composition. See the MessageComposeResult enumeration.

    Discussion

    This method is called when the user taps one of the buttons to dismiss the message composition interface. Your implementation of this method should dismiss the view controller and perform any additional actions needed to process the sending of the message. The result parameter lets you know whether the user chose to cancel or send the message or whether sending the message failed.

    Implementation of this method is required.

    Import Statement

    Objective-C

    @import MessageUI;

    Swift

    import MessageUI

    Availability

    Available in iOS 4.0 and later.