小编OME*_*RMA的帖子

如何在没有SDK的Swift 3中分享Facebook和Twitter应用程序

我需要在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.")

    }

}
Run Code Online (Sandbox Code Playgroud)

twitter facebook ios swift3

4
推荐指数
1
解决办法
6656
查看次数

标签 统计

facebook ×1

ios ×1

swift3 ×1

twitter ×1