[英]How to open Patreon App by using Swift code
我正在查看下面的代码,我们能够打开 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>
你能帮我告诉我如何在info.plist
上添加 Patreon App 吗?
我写这篇评论是为了让你知道我昨天发现了解决方案:
let webURL = NSURL(string: "https://www.patreon.com/\(patreonUserName)")!
let application = UIApplication.shared
application.open(webURL as URL)
这解决了我的问题,我很幸运地发现了:)
此致。
尝试使用以下代码
在 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 文件。这是一个有用的链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.