Using iOS proxy settings automatically in Forms app

BenjaminFunkBenjaminFunk USMember ✭✭
edited August 27 in Xamarin.Forms

I have a client that has devices on premise that need to use a proxy. The proxy isn't for all users of the app, though, so I need my Xamarin Forms app to use the proxy settings on the device if there's something present, and skip it otherwise. The issue appears to only affect the iOS build. The network in question distributes the proxy automatically via DHCP settings to all connected devices. Right now the app is not using those settings and so it can't connect.

For HttpClient Implementation (iOS Build tab of the project settings), I've been using Managed. Should I switch to either NSUrlSession or CFNetwork instead? The minimum requirements and build target for the app are already iOS 9 (for iPad 2 A5 support), so either of those should be compatible not not otherwise restrict us.

Also, good news, the app in question was built with a single helper method to create the HTTP client, add POST data when necessary, and make the request, so if I need to do something in the shared library, it won't be terribly difficult.

The problem is I can't test it without deploying, because I don't have a proxy set up here. So I'm asking y'all if this will cause the device's proxy settings to be used, or if I need to do something else.

Thanks!

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    I think it depends on which kind of proxy the user is using.
    If the proxy is global there's no need to do extra work. Your application will apply the proxy's setting.
    But if the proxy is used for some specific applications we can do nothing in our application. Your own app can't change this behavior.

  • BenjaminFunkBenjaminFunk USMember ✭✭

    They're saying it's for all HTTP/HTTPS traffic. My code uses an HttpWebRequest to make all of its calls, but they're telling me that it's trying to bypass the proxy, which is distributed as part of DHCP on the network. The Android app is using the proxy automatically like it should.

    I switched from Managed to NSUrlSession on the iOS project and put it up on TestFlight. I'm waiting for Apple to approve it for external testers and then I'll invite them to give it a shot. Will report back.

Sign In or Register to comment.