iOS9 an issue with HTTP request failure

Source: Internet
Author: User

The latest project to upgrade the computer version to 10.11.3 Xcode upgrade to 7.2 but when the data request on the emulator to tell me that the network oh, there is a problem

As follows

Through the network finally found a solution to the original is IOS9 using HTTPS

So it needs to be configured for a bit.

Recommended URL: http://segmentfault.com/a/1190000002933776

Finally, the following solutions are found:
    1. Add a type in NSAppTransportSecurity info.plist Dictionary .

    2. NSAppTransportSecurityunder Add NSAllowsArbitraryLoads type, the Boolean value is set toYES

See a lot of students after the modification or can not be added:
    1. Search in Filter Info.plist , select Info.plist to edit

    2. According to the above-mentioned way to add information, the correct changes will see this look, note the type NSAppTransportSecurity Dictionary , NSAllowsArbitraryLoads for Boolean , copy and paste, do not have more space, segment fault page directly copied, often more one out of space!

    3. Note that there is also a unit test below Info.plist , it is not useful to modify that file!

Additional Information

The method described above solves the problem of network access, but the security provided by Apple is also turned off.
However, the closure of this restriction may be a more practical practice, according to the domestic situation.
There are too many reasons, third-party SDKs (almost all Access HTTP ), partner access (they must not be required to support HTTPS).
If your app is not limited by these reasons, it is more recommended that you increase HTTPS support instead of closing the limit.
Please make adjustments according to the actual situation of the project.

For security reasons we advocate use HTTPS , retreat and second, priority use: Add 例外 allowed domains to the configuration list

@banxi1988 complements the method of configuration
For the really unsupported HTTPS should first consider adding例外

The way to add exceptions is also simple:
Left button to Info.plist Selectopen with source code
Then add a configuration similar to the following:

    <Key>nsapptransportsecurity</Key><Dict><Key>nsexceptiondomains</Key><Dict><Key>qq.com</Key><Dict><key>nsincludessubdomains</key > <true/> </ dict> <key>sina.com.cn</key> <dict > <key>nsincludessubdomains< /key> <true/> </dict> </ dict> </DICT>    

Depending on the domain name you need to modify, Nsincludesubdomains, as the name implies, includes subdomain meaning.

iOS9 an issue with HTTP request failure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.