App Transport Security has blocked a cleartext HTTP resource

后端 未结 6 670
不思量自难忘°
不思量自难忘° 2020-12-01 13:15

I am using Socket.IO library in swift and I keep getting this error:

App Transport Security has blocked a cleartext HTTP (http://) resource

6条回答
  •  一整个雨季
    2020-12-01 13:37

    You need to correct it like this:

    To make it easier, this is the correct xml in the info.plist

    NSAppTransportSecurity
        
            NSExceptionDomains
            
                localhost
                
                    NSIncludesSubdomains
                    
                    NSTemporaryExceptionAllowsInsecureHTTPLoads
                    
                    NSTemporaryExceptionMinimumTLSVersion
                    TLSv1.1
                
            
        
    

    change the localhost to your actual server

    Check the table for NSAppTransportSecurity options

    If you want to all communications with any domain, you can do this:

     NSAppTransportSecurity
        
            NSAllowsArbitraryLoads
            
        
    

    However, you should use the latest just in the developing phase.

提交回复
热议问题