【问题标题】:Ask permission to use specific query schemas on iOS 10在 iOS 10 上请求使用特定查询架构的权限
【发布时间】:2017-09-07 09:55:12
【问题描述】:

设置查询方案后做ininfo.plist文件:

<key>LSApplicationQueriesScheme</key>
<array>
    <string>telprompt</string>
    <string>fb-messenger</string>
    <string>tel</string>
</array>

我想这样打开手机提示:

   'let url = URL(string: "telprompt://\(self.offertaObj.callNumber)")
    if UIApplication.shared.canOpenURL(url!) {
        UIApplication.shared.open(url!)

    }else{
        self.view.makeToast("Contattaci al numero: "+self.offertaObj.callNumber, duration: 3, position: .bottom)
    }

我将始终收到应用程序不允许打开该查询方案的消息,同时我没有找到任何关于如何通过 toast 消息请求用户允许它的参考。

【问题讨论】:

    标签: ios user-permissions info.plist


    【解决方案1】:

    现在在 ios 中,架构已更改为执行来自应用程序的调用。执行调用请参考以下代码。

    guard let url: URL = URL(string: "tel://" + "\(phoneNumber)") else {
                                    print("Error in Making Call")
                                    return
                                }
                                if #available(iOS 10.0, *) {
                                    UIApplication.shared.open(url, options: [:], completionHandler: nil)
                                } else {
                                    // Fallback on earlier versions
                                    UIApplication.shared.openURL(url)
                                }
    

    【讨论】:

    • 我尝试了您的解决方案,但没有抛出任何错误。顺便说一句,在模拟器上(当然是iPhone!),无论如何都不会打开手机:你有什么建议吗?
    • 您无法在模拟器中进行调用。您需要在实际设备上进行测试。
    猜你喜欢
    • 1970-01-01
    • 2018-07-29
    • 2017-02-12
    • 2021-03-27
    • 1970-01-01
    • 2016-01-05
    • 1970-01-01
    • 2022-08-02
    • 1970-01-01
    相关资源
    最近更新 更多