【发布时间】:2017-09-10 12:36:38
【问题描述】:
如果通过按钮点击安装在设备中,我需要在 facebook 和 twitter 应用程序上分享一些链接。我可以使用 Whatsapp 分享相同的内容(代码如下)。我想知道我是否可以在 facebook 和 twitter 上做同样的事情应用程序也。
@IBAction func whatsappbtn(_ sender: UIButton) {
var str = "This is the string which you want to share to WhatsApp"
str=str.addingPercentEncoding(withAllowedCharacters: (NSCharacterSet.urlQueryAllowed))!
let whatsappURL = URL(string: "whatsapp://send?text=\(str)")
if UIApplication.shared.canOpenURL(whatsappURL!) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(whatsappURL!, options: [:], completionHandler: nil)
} else {
// Fallback on earlier versions
}
} else {
self.delegate?.alerting(msg: "Please install Whatsapp and try again.")
}
}
【问题讨论】:
标签: ios facebook twitter swift3