我在日志中收到此错误?
虽然我在模拟器上运行它,但这在测试阶段会重要吗?
canOpenURL: failed for URL: "tel://0478733797" - error: "This app is not allowed to query for scheme tel" callNumber button pressed
这是我的函数。
字符串是“0478733797”
func callNumber(phoneNumber:String) {
if let phoneCallURL = URL(string: "tel://\(phoneNumber)") {
let application:UIApplication = UIApplication.shared
if (application.canOpenURL(phoneCallURL)) {
application.open(phoneCallURL, options: [:], completionHandler: nil)
}
}
}
最佳答案
您遇到的错误说明您不允许您的应用程序打开查询方案。要解决这个问题,您应该在 info.plist 中添加以下权限
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
</array>
并在设备而不是模拟器上运行您的应用程序
关于ios - 索要号码功能错误 canOpenURL : failed for URL: "tel://0478733797" - error: "This app is not allowed to query for scheme tel",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49355698/