This topic created in 618 days ago, the information mentioned may be changed or developed.
用 dio 请求后端接口
在模拟器一切正常,到真机提示如下:
DioExceptionType.connectionError The connection errored:Connection failed This indicates an error whichmost likely cannot be solved by the library.
是 dio 的问题吗?接口是 http://ip:port 的形式
已经在 info.plist 里申明了 http 放行
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
 | | 1 whevether Aug 19, 2024 真机是正式打包还是调试开发模式。调试模式没问题。但是正式打包 ios 不管你是不是开了这个允许安全都无效。因为你这个是 app 允许 http ,而 ios 系统强制需要 https 会被 ios 屏蔽。 |
 | | 2 jiuzhougege Aug 19, 2024 @ whevether 解决了,网上搜的 18 年的一个文章,说是 ios 的一个 bug ,但是很少出现,需要在设置-蜂窝网络-修改下任意一个 app 的连接选项即可,试了后果然可以了 |
 | | 3 jiuzhougege Aug 19, 2024 @ whevether release 模式也可以 http ,生命 NSAppTransportSecurity 和 NSAllowsArbitraryLoads 即可 |