gpt4 book ai didi

ios - 给定电话号码,如何在 iOS 中调用电话?

转载 作者:行者123 更新时间:2023-11-28 09:35:53 26 4
gpt4 key购买 nike

我在从 CloudKit 下载的字符串“3133133313”中保存了一个 10 位电话号码。

我想用这个号码打电话。因此,我有 Apple 建议的代码。

    let call = detail.value(forKey: "Phone") as? String
let url = URL(string: call!)!
UIApplication.shared.open(url, options: [:], completionHandler: nil)

不幸的是,这段代码不起作用。我在这里遗漏了什么可能是显而易见的。

最佳答案

感谢 Leo Dabus,

我只需要为每个电话号码添加“tel://”方面。在这个项目中,我决定将此代码片段添加到我的函数中而不是我的 CloudKit 记录中。

if let call = detail.value(forKey: "Phone") as? String,
let url = URL(string: "tel://\(call)"),
UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}

关于ios - 给定电话号码,如何在 iOS 中调用电话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42963260/

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