Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 有没有办法拨打*#06";从我的应用程序中获取用户在我的应用程序中的IMEI屏幕?_Ios_Swift_Iphone - Fatal编程技术网

Ios 有没有办法拨打*#06";从我的应用程序中获取用户在我的应用程序中的IMEI屏幕?

Ios 有没有办法拨打*#06";从我的应用程序中获取用户在我的应用程序中的IMEI屏幕?,ios,swift,iphone,Ios,Swift,Iphone,我正在使用(swift 4.2)。我尝试了下面的代码,但它不适合我 if let url = URL(string: "tel://*#06#"), UIApplication.shared.canOpenURL(url) { if #available(iOS 10, *) { UIApplication.shared.open(url) } else { UIApplication

我正在使用(swift 4.2)。我尝试了下面的代码,但它不适合我

if let url = URL(string: "tel://*#06#"), UIApplication.shared.canOpenURL(url) {
            if #available(iOS 10, *) {
                UIApplication.shared.open(url)
            } else {
                UIApplication.shared.openURL(url)
            }
        }
我希望用户设备能够输出IMEI屏幕,但目前我无法将其存档。

以下是解决方案

let getIMEIScreen = "tel://*#06#"
        if let encoded = getIMEIScreen.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed),
            let url = URL(string: encoded) {
            if #available(iOS 10, *) {
                UIApplication.shared.open(url)
            } else {
                UIApplication.shared.openURL(url)
            }
        }

我们不允许在URL中直接传递特殊字符,因此我们需要对其进行编码并将其传递给URL。

您是否在info.plist中添加了
LSApplicationQueriesSchemes
?否,您不能用#或*拨打URL以防止fraud@chirag90是的,我在info.plist文件中添加了密钥,但它根本不起作用。