我必须与Message App共享文本和URL。
if (MFMessageComposeViewController.canSendText()) {
let controller = MFMessageComposeViewController()
//controller.subject = "http://www.appzoy.com"
//controller.attachments?.append(["url" : URL(string : "http://www.appzoy.com")!])
//controller.addAttachmentURL(URL(string : "http://www.appzoy.com")!, withAlternateFilename: "")
controller.body = "Hey I just gave an Awesome Assessment on UAssess App you can also try it. I scored \(String(describing: myScore!)) , Try to beat my score"
controller.messageComposeDelegate = self
self.present(controller, animated: true, completion: nil)
}
else {
Helper.sharedInstance.Print("No Message Composer Present" as AnyObject)
}.
我也试图传递网址,但它不会向App发送消息 任何人都知道如何在消息应用程序中共享URL链接和文本。
答案 0 :(得分:2)
尝试以下代码:
let controller = MFMessageComposeViewController()
if (MFMessageComposeViewController.canSendText()) {
let urlToShare = "http://www.appzoy.com"
controller.body = "Hey I just gave an Awesome Assessment on UAssess App you can also try it. I scored , Try to beat my score \(urlToShare)"
controller.messageComposeDelegate = self
self.present(controller, animated: true, completion: nil)
}