Reputation: 269
I saw there is message
property in MFMessageComposeViewController. Can we construct an MSMessage and assign it to MFMessageComposeViewController, then share this message in new iMessage App without developing an extension? If we can do that, we can share other with a message with images and title, instead of just plain string or attachment before iOS 10.
Upvotes: 2
Views: 488
Reputation: 269
From what I learn here https://forums.developer.apple.com/thread/49922, you need to create an imessage extension target (you don't need to do any develop for the target) , then you can share the msmessage in MFMessageComposeViewController
This is the demo in the link above:
Wrote the code below
import UIKit
import Messages
import MessageUI
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func onTouchUp(_ sender: AnyObject) {
let composeVC = MFMessageComposeViewController()
let msgLayout = MSMessageTemplateLayout()
msgLayout.caption = "something here"
let message = MSMessage()
message.layout = msgLayout
composeVC.message = message
self.present(composeVC, animated: true, completion: nil)
}
}
Upvotes: 1