当我使用canOpenURL打开通用链接时,(目标应用已安装)
canOpenURL返回true,但应用程序未打开(未注册LSApplicationQueriesSchemes)
但如果我使用open(_ url, options)应用程序正在打开
如果我要为没有注册LSApplicationQueriesSchemes负责,我如何注册LSApplicationQueriesSchemes的通用链接?(https://www.aaa.com)
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https://www.aaa.com</string>
</array>是像这样吗?
发布于 2020-03-25 01:22:46
如果AAA是你试图打开的应用,还有另一种方法可以从你的应用内部启动它。您需要获取目标应用程序使用的CFBundleURLSchemes。
AAA的"aaamobile“和AAA汽车俱乐部的"aaamobileace”
然后,您需要将url方案添加到plist中:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>aaamobile</string>
</array>然后在您的代码中,您可以检查应用程序是否已安装,并启动应用程序或将用户带到网站:
guard let url = URL(string: "aaamobile://") else { return }
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.open(URL(string: "https://www.aaa.com")!, options: [:], completionHandler: nil)
}https://stackoverflow.com/questions/60828031
复制相似问题