我需要分享一些鏈接的Facebook和Twitter應用程序,如果安裝在設備上的按鈕tap.I可以共享相同使用WhatsApp(代碼如下)。我想知道我是否也可以在Facebook和Twitter應用程序中做同樣的事情。如何分享Facebook和Twitter應用程序在Swift 3沒有SDK
@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.")
}
}
日Thnx,但我需要沒有SDK代碼。 –