ios - 索要号码功能错误 canOpenURL : failed for URL: "tel://0478733797" - error: "This app is not allowed to query for scheme tel"

标签 ios swift

我在日志中收到此错误?

虽然我在模拟器上运行它,但这在测试阶段会重要吗?

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/

相关文章:

ios - 你如何快速设置 Mapbox map 的间距?

ios - 使用 swift 从解析的 Json 中提取数据

ios - 使用 UIImageJPEGRepresentation() 压缩的图像的 NSData 长度

ios - 找不到扩展的主机目标

ios - '#selector' 的参数不能引用全局函数 (Swift)

ios - 将位置标记定位在位置之上?

cocoa - 如何在 swift 应用程序中使用 sparkle updater?

ios - JSON 解析成功后本应存储 JSON 的数组为空

iOS:通过应用程序登录 Facebook

ios - UICollectionView:删除单元格之间的空间(每行 7 个项目)