Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.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
canOpenURL失败,但打开的outlook iOS可用_Ios_Swift3_Url Scheme - Fatal编程技术网

canOpenURL失败,但打开的outlook iOS可用

canOpenURL失败,但打开的outlook iOS可用,ios,swift3,url-scheme,Ios,Swift3,Url Scheme,我也看到了许多与我的问题相关的堆栈溢出问题,我已经实现了他们提到的所有东西,但仍然不起作用。在标记复制之前,请仔细检查我的完整问题,我已经实现了所有必需的更改 我正在尝试从我的应用打开outlook邮件客户端应用。请查找下面的代码 let url = URL(string: "ms-outlook://compose?to=Feedback@myDomain.com&subject=Mobile%20App%20Feedback") if UIApplication.share

我也看到了许多与我的问题相关的堆栈溢出问题,我已经实现了他们提到的所有东西,但仍然不起作用。在标记复制之前,请仔细检查我的完整问题,我已经实现了所有必需的更改

我正在尝试从我的应用打开outlook邮件客户端应用。请查找下面的代码

let url = URL(string: "ms-outlook://compose?to=Feedback@myDomain.com&subject=Mobile%20App%20Feedback")
     if UIApplication.shared.canOpenURL(url!) {
        UIApplication.shared.open(url!)
    }
    else
    {
          AppDelegate.sharedDelegate().getRootViewController().showAlert(title: "Cannot send email", message: "There is no Outlook app installed on your device device.")
    }
我也在plist中添加了msoutlook

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>ms-outlook</string>
</array>

我也在真实设备上测试。如果我删除canOpenURL检查并直接打开url,则该url工作正常。我不知道我错过了什么。提前谢谢。

我想出了另一个选择

  let scheme : String = "ms-outlook://compose?to=Feedback@myDomain.com&subject=Mobile%20App%20Feedback"

    if let url = URL(string: scheme) {
        UIApplication.shared.open(url, options: [:], completionHandler: {
            (success) in
            if (success)
            {
                print("Open \(scheme): \(success)")
            }
            else
            {
                AppDelegate.sharedDelegate().getRootViewController().showAlert(title: "Cannot send email", message: "There is no Outlook app installed on your device.")
            }
        })
    }

可能的副本或。。。在您发布的代码中,什么是urlScheme!?如果我将其替换为.canOpenURLurl!它工作正常-我得到一个失败的URL:ms-outlook://... 错误消息和if失败与不允许查询消息相反我已更新我的问题,键入错误。@DonMag:如果我的问题重复,缺少的答案在哪里。如果您使用粘贴在此处的确切代码,而不是重新键入,您仍然不允许查询吗?如果您将let url=行更改为简单https://apple.com 您是否得到同样的不允许查询?
  let scheme : String = "ms-outlook://compose?to=Feedback@myDomain.com&subject=Mobile%20App%20Feedback"

    if let url = URL(string: scheme) {
        UIApplication.shared.open(url, options: [:], completionHandler: {
            (success) in
            if (success)
            {
                print("Open \(scheme): \(success)")
            }
            else
            {
                AppDelegate.sharedDelegate().getRootViewController().showAlert(title: "Cannot send email", message: "There is no Outlook app installed on your device.")
            }
        })
    }