【问题标题】:Open Facebook app using Facebook link page with Swift使用 Swift 的 Facebook 链接页面打开 Facebook 应用程序
【发布时间】:2019-09-09 05:12:32
【问题描述】:

在 Google 和 Stackoverflow 上多次搜索后,我找不到解决问题的方法。

目前,我的应用通过 Safari 打开一个 Facebook 页面。但我希望在 Facebook 应用程序中自动打开同一页面。请问您有什么解决办法吗?

这是我实现的代码,但 Facebook 应用程序无法打开...

@IBAction func facebookButton(_ sender: Any) {

    if let appURL = URL(string: "facebook://") {

        let canOpen = UIApplication.shared.canOpenURL(appURL)
        print("\(canOpen)")

        let appName = "Facebook"
        let appScheme = "\(appName)://"
        let appSchemeURL = URL(string: appScheme)

        if

            UIApplication.shared.canOpenURL(appSchemeURL! as URL) {
            UIApplication.shared.open(appSchemeURL!, options: [:], completionHandler: nil)

        } else {

            let alert = UIAlertController(title: "\(appName) Erreur !", message: "L'application \(appName) ne peut pas s'ouvrir. Merci de l'installer depuis l'App Store.", preferredStyle: .alert)

            alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))

            self.present(alert, animated: true, completion: nil)
        }
    }
}

【问题讨论】:

    标签: ios swift facebook


    【解决方案1】:

    您是否在 info.plist 中将 facebook 方案添加到 LSApplicationQueriesSchemes 中?

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>facebook sceheme here</string>
    </array>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-30
      • 2011-06-16
      相关资源
      最近更新 更多