NSURLSession/NSURLConnection HTTP load failed on iOS 9

前端 未结 13 1017
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 05:20

Tried to run my existing app on iOS9 but getting failure while using AFURLSessionManager.

__block NSURLSessionDataTask *task = [self.sessionMana         


        
相关标签:
13条回答
  • 2020-11-22 05:48

    I have solved it with adding some key in info.plist. The steps I followed are:

    I Opened my project's info.plist file

    Added a Key called NSAppTransportSecurity as a Dictionary.

    Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image. enter image description here

    Clean the Project and Now Everything is Running fine as like before.

    Ref Link: https://stackoverflow.com/a/32609970

    0 讨论(0)
  • 2020-11-22 05:51

    I found solution from here. And its working for me.

    Check this, it may help you.

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
             <dict>
                 <key>myDomain.com</key>
                        <dict>
                          <!--Include to allow subdomains-->
                          <key>NSIncludesSubdomains</key>
                          <true/>
                          <!--Include to allow HTTP requests-->
                          <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                          <true/>
                          <!--Include to specify minimum TLS version-->
                          <key>NSTemporaryExceptionMinimumTLSVersion</key>
                          <string>TLSv1.1</string>
                    </dict>
              </dict>
    </dict>
    
    0 讨论(0)
  • 2020-11-22 05:54

    You can try add this function in file RCTHTTPRequestHandler.m

    - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); }

    0 讨论(0)
  • 2020-11-22 05:55

    Simply add the following fields in your .plist file

    Syntax looks like this:

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    
    0 讨论(0)
  • 2020-11-22 05:57

    You should add App Transport Security Settings to info.plist and add Allow Arbitrary Loads to App Transport Security Settings

    <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
    
    0 讨论(0)
  • Update:

    As of Xcode 7.1, you don't need to manually enter the NSAppTransportSecurity Dictionary in the info.plist.

    It will now autocomplete for you, realize it's a dictionary, and then autocomplete the Allows Arbitrary Loads as well. info.plist screenshot

    0 讨论(0)
提交回复
热议问题