How can I connect to an api with http from iOS emulator?

Hamittirpan 166 Reputation points
2020-11-23T11:21:04.127+00:00

Hi everyone !

I cannot test the api because iOS does not allow http urls. Is there any way to allow http?
I used to have a method, but I think that method was removed.
I will be glad if you help.

Thanks in advance !

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,491 Reputation points Microsoft Vendor
    2020-11-23T12:20:53.18+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    If your app needs to load and display web content from non-secure sites, add the following to your app's Info.plist file to allow web pages to load correctly while Apple Transport Security (ATS) protection is still enabled for the rest of the app:

       <key>NSAppTransportSecurity</key>  
       <dict>  
         <key> NSAllowsArbitraryLoadsInWebContent</key>  
         <true/>  
       </dict>  
    

    Optionally, you can make the following changes to your app's Info.plist file to completely disable ATS for all domains and internet communication:

       <key>NSAppTransportSecurity</key>  
       <dict>  
         <key>NSAllowsArbitraryLoads</key>  
         <true/>  
       </dict>  
    

    Here is offical article:
    https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/ats#opting-out-of-ats

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful