简体   繁体   English

呼叫号码功能错误canOpenURL:URL失败:“ tel:// 0478733797”-错误:“此应用程序不允许查询方案tel”

[英]Call number function error canOpenURL: failed for URL: “tel://0478733797” - error: “This app is not allowed to query for scheme tel”

I am getting this error in the log? 我在日志中收到此错误?

Though I am running this on the simulator, will this matter in the testing stage? 尽管我在模拟器上运行此程序,但在测试阶段这有关系吗?

canOpenURL: failed for URL: "tel://0478733797" - error: "This app is not allowed to query for scheme tel" callNumber button pressed canOpenURL:URL失败:“ tel:// 0478733797”-错误:“不允许此应用程序查询方案tel” callNumber按钮

Here is my function. 这是我的功能。

The string is "0478733797" 字符串是“ 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)

        }
    }
}

The error you are facing describes that you have not allowed your app to open an query scheme. 您面临的错误说明您不允许您的应用打开查询方案。 To solve that you should add following permission in your info.plist 为了解决这个问题,您应该在info.plist中添加以下权限

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>tel</string>
    </array>

And run your application on the Device instead of Simulator 并在设备而不是模拟器上运行您的应用程序

To make a call to a number, you simply need to do this: 要拨打电话,您只需要执行以下操作:

let urlSchema = "tel:"
let numberToCall = "0478733797"
if let numberToCallURL = URL(string: "\(urlSchema)\(numberToCall)")
{
    if UIApplication.shared.canOpenURL(numberToCallURL)
    {
        UIApplication.shared.openURL(numberToCallURL)
    }
}

Only the URL that you are creating using tel: is not in the correct format. 仅使用tel:创建的URL格式不正确。

There is no need to add anything to the Info.plist . 无需向Info.plist添加任何内容。 Also, call is not supported on an iOS Simulator . 另外, iOS Simulator不支持通话。 So try running it on an actual device. 因此,请尝试在实际设备上运行它。

Let me know if you still face any issues. 让我知道您是否仍然遇到任何问题。 Happy Coding..🙂 快乐编码..🙂

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 canOpenURL:URL 失败:“instagram://”- 错误:“不允许此应用查询方案 instagram” - canOpenURL: failed for URL: "instagram://" - error: "This app is not allowed to query for scheme instagram" -canOpenURL:URL失败:“fbauth2:/” - 错误:“此应用程序不允许查询方案fbauth2”(OSStatus错误-10814。) - -canOpenURL: failed for URL: “fbauth2:/” - error: “This app is not allowed to query for scheme fbauth2” (OSStatus error -10814.) canOpenURL:URL 失败:“instagram://app” - 错误:“此应用程序不允许查询方案 instagram” - canOpenURL: failed for URL: “instagram://app” - error: “This app is not allowed to query for scheme instagram” swift3 - canOpenURL:URL 电话失败 - swift3 - canOpenURL: failed for URL tel URL 失败:“消息://”- 错误:“不允许此应用查询方案消息” - failed for URL: "message://" - error: "This app is not allowed to query for scheme message" canOpenUrl - 此应用不允许查询方案 instragram - canOpenUrl - This app is not allowed to query for scheme instragram 自定义 URL 方案错误:此应用不允许查询方案 - Custom URL Scheme Error : This app is not allowed to query for scheme iPod Touch canOpenURL类型为tel:// - iPod Touch canOpenURL of type tel:// tel:// 方案自动格式化电话号码 - tel:// scheme automatically formats the phone number -canOpenURL:URL失败:“fbauth2:/” - 错误:“(null)” - -canOpenURL: failed for URL: “fbauth2:/” - error: “(null)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM