V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
jiuzhougege
V2EX  ›  Flutter

flutter 开发的 APP 安装到真机接口请求异常

  •  
  •   jiuzhougege · 32 天前 · 735 次点击
    这是一个创建于 32 天前的主题,其中的信息可能已经有所发展或是发生改变。
    用 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>
    3 条回复
    whevether
        1
    whevether  
       30 天前
    真机是正式打包还是调试开发模式。调试模式没问题。但是正式打包 ios 不管你是不是开了这个允许安全都无效。因为你这个是 app 允许 http ,而 ios 系统强制需要 https 会被 ios 屏蔽。
    jiuzhougege
        2
    jiuzhougege  
    OP
       30 天前
    @whevether 解决了,网上搜的 18 年的一个文章,说是 ios 的一个 bug ,但是很少出现,需要在设置-蜂窝网络-修改下任意一个 app 的连接选项即可,试了后果然可以了
    jiuzhougege
        3
    jiuzhougege  
    OP
       30 天前
    @whevether release 模式也可以 http ,生命 NSAppTransportSecurity 和 NSAllowsArbitraryLoads 即可
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4885 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 01:11 · PVG 09:11 · LAX 18:11 · JFK 21:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.