1

我正在查看下面的代码,我们可以打开 facebook 或 twitter iOS 应用程序,但是有没有办法为 Patreon 应用程序做到这一点?

    let appURL = NSURL(string: "fb://profile/\(facebook)")!
    let webURL = NSURL(string: "https://www.facebook.com/\(facebook)")!
    let application = UIApplication.shared

    if application.canOpenURL(appURL as URL) {
        application.open(appURL as URL)
    } else {
        application.open(webURL as URL)
    }

我还在 Info.plist 中包含以下几行:

<array>
    <string>instagram</string>
    <string>fb</string>
</array>

你能帮我告诉我如何添加Patreon Appinfo.plist吗?

4

2 回答 2

1

我写这篇评论是为了让你知道我昨天发现了解决方案:

let webURL = NSURL(string: "https://www.patreon.com/\(patreonUserName)")!
let application = UIApplication.shared

    application.open(webURL as URL)

这解决了我的问题,我只是幸运地发现了:)

此致。

于 2020-06-11T13:42:21.390 回答
0

尝试使用以下代码

在 Plist 文件中,添加以下内容 -

<string>com.patreon.iphone</string>

现在像 FB 一样从应用程序调用。我已经使用以下代码在更新的 Xcode(11.4 和 swift 5.x)中进行了测试,该代码运行良好 -

func open(scheme: String) {
      if let url = URL(string: scheme) {
        UIApplication.shared.open(url, options: [:], completionHandler: {
          (success) in
          print("Open \(scheme): \(success)")
        })
      }
    }

称呼:

self.open(scheme: "com.patreon.iphone://")

注意:并非所有应用都有 Url 架构。如果您需要了解 URL 架构,请下载 IPA 并使用此 Apple Configurator 2 查看第三方应用程序的 plist 文件。这是一个有用的链接

于 2020-05-18T06:44:52.950 回答