简体   繁体   English

UIApplication.shared.open 仅适用于 https

[英]UIApplication.shared.open only works with https

I trying to open url with UIApplication.shared.open function but i'm little bit confused because its not working for www.google.com and its working for https://www.google.com . I trying to open url with UIApplication.shared.open function but i'm little bit confused because its not working for www.google.com and its working for https://www.google.com .

struct GetIsoCode: View {
    @State var titile = "www.google.com"
    var body: some View {
        Text(titile)
            .onTapGesture {
                let urlS = URL(string:titile)
                if let url = urlS {
                    UIApplication.shared.open(url) { (response) in
                        print(response)
                    }
                }
            }
    }
}

First Use case:第一个用例:

Input url:输入 url:

www.google.com www.google.com

Output: Output:

Failed to open URL www.google.com : Error Domain=NSOSStatusErrorDomain Code=-50 "invalid input parameters" UserInfo={NSDebugDescription=invalid input parameters, _LSLine=234, _LSFunction=-[_LSDOpenClient openURL:options:completionHandler:]}无法打开 URL www.google.com : Error Domain=NSOSStatusErrorDomain Code=-50 "invalid input parameters" UserInfo={NSDebugDescription=invalid input parameters,_LSLine=234,_LSFunction:-completionD102C5FE6AD1C50DA4BEC50Z

Second Use case:第二个用例:

Input:输入:

https://www.google.com https://www.google.com

Result: It's working fine.结果:工作正常。

Can someone please explain to me how to show google from both links, I've tried to implement by above but no results yet.有人可以向我解释如何从两个链接中显示谷歌,我已经尝试通过上面的方法实现,但还没有结果。

The docs say:文档说:

UIKit supports many common schemes, including the http, https, tel, facetime, and mailto schemes. UIKit 支持许多常用方案,包括 http、https、电话、面谈和邮寄方案。

Use this method to open the specified resource.使用此方法打开指定的资源。 If the specified URL scheme is handled by another app, iOS launches that app and passes the URL to it.如果指定的 URL 方案由另一个应用程序处理,则 iOS 启动该应用程序并将 URL 传递给它。 (Launching the app brings the other app to the foreground.) If no app is capable of handling the specified scheme, the completion handler is called with the success parameter set to NO. (启动应用程序会将另一个应用程序带到前台。)如果没有应用程序能够处理指定的方案,则会调用完成处理程序,并将成功参数设置为 NO。

To determine whether an app is installed that is capable of handling the URL, call the canOpenURL: method before calling this one要确定是否安装了能够处理 URL 的应用程序,请在调用此之前调用 canOpenURL: 方法

  1. Which URL scheme would the string "www.google.com" be?字符串“www.google.com”是哪个URL 方案
  2. Call canOpenURL first, before calling open(url:)先调用 canOpenURL,再调用 open(url:)

暂无
暂无

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

相关问题 UIApplication.shared.open添加标题数据 - UIApplication.shared.open Add Header Data UIApplication.shared.open 在 ios 13 中不起作用 - UIApplication.shared.open is not working in ios 13 UIApplication.shared.open, swift 完成一个连接处理 - UIApplication.shared.open , swift completion of a connection handling UIApplication.shared.open(url) 算作加密吗? - Does UIApplication.shared.open(url) count as encryption? iOS 14.5 或 14.6 及更高版本访问共享扩展中的 UIApplication.shared.open 或 UIApplication.shared.openURL 给出“APPLICATION_EXTENSION_API_ONLY” - iOS 14.5 or 14.6 onwards accessing UIApplication.shared.open or UIApplication.shared.openURL in Share Extension gives "APPLICATION_EXTENSION_API_ONLY" UIApplication.shared.open(_ url:URL等)没有打开任何东西 - UIApplication.shared.open(_ url: URL,etc.) doesn't open anything Gmail 有没有办法从 UIapplication.shared.open url 的文本中识别换行符 - Is there a way for Gmail to recognize line breaks from text from UIapplication.shared.open url 用户通知接收响应方法是否允许我将更新的变量传递给UIApplication.shared.open()? - User-Notification Did Receive Response Method Does not allow me to Pass Updated Variable to UIApplication.shared.open() ? UIApplication 没有成员共享 - UIApplication has no member shared 我的应用程序是否使用 UIApplication.shared.openURL 调用 HTTPS? - Does my app make a call to HTTPS using UIApplication.shared.openURL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM