1

I'm trying to send MMS programatically. I followed this question&answer: how to send MMS from iPhone app

When translated to Swift, it looks like this:

@IBAction func sendMMSButtonPressed(sender: UIButton) {
        if !MFMessageComposeViewController.canSendText(){
            return
        }

        let phoneToCall = "sms"
        let phoneToCallEncoded = phoneToCall.stringByAddingPercentEscapesUsingEncoding(NSASCIIStringEncoding)
        let url = NSURL(string: phoneToCallEncoded!)!
        UIApplication.sharedApplication().openURL(url)

        let pasteboard = UIPasteboard.generalPasteboard()
        pasteboard.persistent = true
        pasteboard.image = UIImage(named: "slow")
        let messageController = MFMessageComposeViewController()
        messageController.messageComposeDelegate = self
        messageController.body = "What an awesome app"

        self.presentViewController(messageController, animated: true, completion: nil)

    }

The problem is that image is not automatically added to message, hence I am only sending sms and not mms. What is the correct way of sending images? I don't want to use iMessages since I want the user to be able to send MMS's to Android,Windows... users as well. Thanks for your help!

Community
  • 1
  • 1
sanjihan
  • 5,592
  • 11
  • 54
  • 119
  • You're calling both openURL() and presentViewController(). Probably not what you wanted. And check http://stackoverflow.com/questions/19170516/mfmessagecomposeviewcontroller-ios7-addattachmentdatatypeidentifierfilename-n regarding attachments in MFMessageComposeViewController – Mattias Aug 11 '15 at 15:06
  • I'm not seeing you have attached any media file to the message... – holex Aug 11 '15 at 15:19
  • I'm just following the question&answer mentioned above. – sanjihan Aug 11 '15 at 15:53
  • @Undeph thanks for the link, it helped a lot. Too bad I can't accept comment :D – sanjihan Aug 11 '15 at 16:00

0 Answers0