Search code examples
iphoneobjective-cxcodemfmessagecomposeviewcontroller

Get message body and recipients list from MFMessageComposeViewController


Is there a legal way to get body text and recipients list from MFMessageComposeViewController after SMS was sent(in didFinishWithResult callback delegate)?

I have an application which sends SMS and saves it in history. I'm using MFMessageComposeViewController for sending SMS. This is needed in order to save message correctly to history and perform searches.

  • I know there is no way to change body and recipients list after controller was shown, i want to get them.
  • I know there is phone's SMS history - but i need this in history of my application due to specific functionality of application according message body.

Solution

  • There is an official "legal" standard way to do this:

    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
    
    
        NSString *sms = controller.body;
    

    Same with controller.recipients...