gpt4 book ai didi

ios - 用于打开其他应用程序的 canOpenURL - 不适用于模拟器

转载 作者:搜寻专家 更新时间:2023-10-31 22:11:41 24 4
gpt4 key购买 nike

我正在尝试从部署目标为 8.1 的应用程序中打开 Yelp

我面临的问题是我的代码没有在模拟器上正确评估。我的设备是 iOS 10.3,它在那里运行良好(Yelp 打开),但我需要能够检查它是否适用于旧版本 iOS 的模拟器!

    let urlStr: String = "yelp://"
let url = URL(string: urlStr)
if UIApplication.shared.canOpenURL(url!) {
print("can open")
if #available(iOS 10.0, *) {
print("10")
UIApplication.shared.open(url!, options: [:], completionHandler: nil)
} else {
print("NOT 10")
UIApplication.shared.openURL(url!)
}
}
else {
// Can not open URL
print("can not open url")
}

在模拟器 (iOS 8.1) 中,以下内容打印到控制台:

can open
NOT 10

但是,这是错误的! Yelp 未安装在模拟器上 - 但如果是这样,print("can not open url") 不会评估吗??

这是我在 info.plist 中的 URLTypes/LSApplicationQueriesSchemes。

Here's my URLTypes / LSApplicationQueriesSchemes in the info.plist.

我上面的代码有什么问题吗?如何在模拟器上正确测试 Yelp 的打开,我可以在模拟器上对各种 iOS 版本(从 8.1 开始)进行质量检查?谢谢 friend 。

最佳答案

它返回 true 因为在您的 URL Schemes 中,您有一个项目 yelp,基本上当您调用 openURL 。更改该项目并再次测试。

关于ios - 用于打开其他应用程序的 canOpenURL - 不适用于模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43418953/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com