Search code examples
iosswiftipadtestflightnsurlsessiondatatask

iOS 9+ Testflight Cellular Data Not Working


I have a mobile iOS app written in Swift 2. Inside the application there is a call to our server through

Session.dataTaskWithRequest(request, completionHandler: (func))

I have 3 iPads with Cellular data. 1 internal, which I have access to and can hook up to a debugger. 2 external that I have no access to and must ask questions to get an idea of whats going on.

The internal iPad works with build X on both WiFi and Cellular, by works I mean that the request goes through and contacts the server fine.

The external iPads work over WiFi but do not work over cellular.

We have tried

  • Ensuring Mobile Data is on, & on for the specific app
  • Toggling Airplane mode
  • Resetting network
  • Restarting Device
  • Make sure that the devices actually had a connection when the dataTaskWithRequest failed.

Any ideas of what may be going on here? Is there a setting a missed? A setting in the info.plist (why does 1 work) that I've missed?


Solution

  • So dgatwood was on the right track.

    The requests inside the app were being rerouted to an external server in some cases, and an internal server in other cases. Since these requests originated from WKWebView they had the standard HTTPHeaderFields that come from WKWebView. Since these request were pointing inwards at a mini server written to live in the background of the app these three headers contained incorrect information for the request

    • Origin
    • Referer
    • Host

    Over a cooperate data plan there was filtering happening for the requests. Since the origin declared in the header fields did not match the origin of the call, the cellular network was dropping the requests and they were never actually reaching the server.

    The issue was corrected by

    request.setValue(nil, forHTTPHeaderField: "Origin")
    request.setValue(nil, forHTTPHeaderField: "Host")
    request.setValue(nil, forHTTPHeaderField: "Referer")
    

    Hopefully someone finds this helpful at some point