【问题标题】:how to share post on facebook or google using URLScheme如何使用 URLScheme 在 facebook 或 google 上分享帖子
【发布时间】:2018-07-17 15:54:12
【问题描述】:

我想在 facebook 上分享一个 HTML 链接,而无需安装 SDK,例如 WhatsApp 或 twitter。我正在使用以下代码在 facebook 上分享链接。但我想在没有打开 Safari 浏览器的情况下将帖子分享到 Direct 应用程序。 请告诉我这是否可能。我已经搜索了很多但没有找到任何解决方案。

//For share twitter

let urlWhats = "twitter://post?message=\(fileURL)"
let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)
let whatsappURL = URL(string: urlString!)
if UIApplication.shared.canOpenURL(whatsappURL!)
{
    UIApplication.shared.open(whatsappURL!, options: [:], completionHandler: nil)
}


//For Facebook
let shareURL = "https://www.facebook.com/sharer/sharer.php?u=" + url

if let url = URL(string:shareURL)
{
    let vc = SFSafariViewController(url: url, entersReaderIfAvailable: true)
    vc.delegate=self
    present(vc, animated: true)
}

提前致谢

【问题讨论】:

    标签: ios swift facebook google-plus share


    【解决方案1】:

    要在 FB 中分享,请使用“FacebookShare”

    import FBSDKShareKit
    
    class yourViewController: UIViewController {
    
    func shareContentInFB()  {
    
    
    let content = FBSDKShareLinkContent()
    
            content.contentURL =  URL(string: "http://yourURL/")
            content.quote = "Hey !!!!"
            let dialog : FBSDKShareDialog = FBSDKShareDialog()
            dialog.fromViewController = self
            dialog.shareContent = content
            dialog.mode = FBSDKShareDialogMode.automatic
            dialog.show()
         }
    }
    

    你不能使用这个在 fb 中预填充文本,如果你必须这样做,那么使用 Fb graph API

    【讨论】:

    • 我想在不安装 Facebook SDK 的情况下分享。
    • 然后使用原生分享
    • 原生分享方式?
    • 使用 UIActivityViewController,可以将内容分享给您设备中所有已安装的应用程序
    • 但我想在没有 UIActivityViewController 的情况下分享。我创建了一个自定义共享对话框。
    猜你喜欢
    • 2018-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多