我必须将文本和 URL 分享到 Message App。
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)
}.
我也在尝试传递 url,但它不会向 App 发送消息
任何人都知道如何在消息应用程序中共享 URL 链接和文本。
Best Answer-推荐答案 strong>
试试下面的代码:
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)
}
希望这会对你有所帮助
关于ios - 如何使用 swift 3 在消息应用程序中共享 URL 和文本,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/46314087/
|