ios - App Transport Security 阻止通过自定义 url 方案进行路由

标签 ios swift react-native url-scheme

我的 iOS 应用程序(用 Swift 和 React Native 编写)有一个自定义的 url 方案,允许我从例如像这样的 Safari myappscheme://https://www.mywebsite.com/somematerial .如果我在我的应用程序中启用应用程序传输安全性,通过自定义 url 方案的路由将被阻止,我会收到此消息:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

但是,如果我禁用 ATS,应用程序会按预期进行路由。我没有在我的应用程序中通过 http 访问任何链接,在我的路由中我总是通过 https 获取数据。因此,我不知道为什么 ATS 会阻止此路由。你知道我是否需要提供一些关于我的 url scheme 的额外信息吗?

请在 Info.plist 中查看我的 ATS 配置:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

我还将我的自定义 url 方案列入白名单:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>myappscheme</string>
</array>

最佳答案

这个问题已经解决了。我注销了我正在点击的端点,并通过在终端中执行以下操作来检查它是否满足 ATS 要求:

nscurl --ats-diagnostics https://www.example.com/

事实证明,我尝试获取的特定子域未满足所有 ATS 要求。我的服务器团队已解决该问题并使端点安全。

关于ios - App Transport Security 阻止通过自定义 url 方案进行路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42717706/

相关文章:

ios - 出现键盘时更改约束 - Swift

html - 在 iOS 上禁用双击缩放。用户可扩展性不能完全发挥作用

iOS 8 自定义键盘 self.view.frame 返回 0

ios - Firebase iOS swift : Updating TableView After Removing A Child

javascript - 出现错误 Invariant Violation 试图让帧超出范围索引?

c# - Iphone 移动应用程序中的圆形图像范围 (Xamarin.Ios/C#)

ios - 解包读取 JSON 的可选值时意外发现 nil

ios - 如何在 iOS 中为不断闪烁的灯光制作动画?

android - React Native 无法打开任何 URL

ios - Native View 呈现 React Native View