ios - 如何使用 swift 3 在消息应用程序中共享 URL 和文本
<p><p>我必须将文本和 URL 分享到 Message App。 </p>
<pre><code>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)
}.
</code></pre>
<p>我也在尝试传递 url,但它不会向 App 发送消息
任何人都知道如何在消息应用程序中共享 URL 链接和文本。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>试试下面的代码:</p>
<pre><code> 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)
}
</code></pre>
<p> <a href="/image/RWBKQ.png" rel="noreferrer noopener nofollow"><img src="/image/RWBKQ.png" alt="enter image description here"/></a>
希望这会对你有所帮助:)</p></p>
<p style="font-size: 20px;">关于ios - 如何使用 swift 3 在消息应用程序中共享 URL 和文本,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/46314087/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/46314087/
</a>
</p>
页:
[1]