iOS HTTP Request Over Mobile Data

In one of my application I need to make HTTP request on 2G/3g/4g only. If device is connected to Wifi and mobile data both, I need to check and make HTTP request over mobile data. I don't want to turn ON/OFF Wifi.

Is it possible to do so ?

Any sample code or tutorial link will be highly appreciated.

Replies

Is it possible to do so ?

It is not possible to do this with our high-level APIs. Why do you need this? I presume you have a good reason, in which case I recommend that you put that reason into a bug report requesting that NSURLSession support this.

With low-level APIs you can force a particular TCP connection to run over a particular interface, which allows this sort of thing. It's kinda ugly those, not least because you have to build your own HTTP implementation on top of the TCP connection you're using.

I posted about this extensively on the old DevForums:

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"