【问题标题】:NSAppTransportSecurity & FacebookNSAppTransportSecurity 和 Facebook
【发布时间】:2015-12-18 03:06:30
【问题描述】:

在 iOS 9 下,我的 UIWebview 加载公司的 Facebook 页面只能在 NSAllowsArbitraryLoads 键设置为 YES 的情况下工作,否则会导致以下错误:

NSURLSession/NSURLConnection HTTP 加载失败 (kCFStreamErrorDomainSSL, -9802)

有什么建议吗?

【问题讨论】:

    标签: ios9 xcode7 nsapptransportsecurity


    【解决方案1】:

    将您的 Info.plist 文件作为源代码打开并确保“NSAppTransportSecurity”键看起来像这样(更多信息请参见https://developers.facebook.com/docs/ios/ios9

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>facebook.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>                
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>fbcdn.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>akamaihd.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>
    

    【讨论】:

    • 非常感谢您抽出宝贵的时间,顺便说一下它对 twitter 和 youtube 都有效
    猜你喜欢
    • 2015-10-13
    • 1970-01-01
    • 2016-01-18
    • 2015-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    • 2015-12-19
    相关资源
    最近更新 更多