Force Mobile Data usage on some API calls and other to be through wifi or the available network

I am working on an application where there is a need to do a specific API only through Mobile Data and not wifi, allowing other API calls to be done using the available network type whether cellular data or wifi or ....

Is there a way to force use Mobile data usage even if WIFI is ON on this API call.

Replies

Is there a way to force use Mobile data usage even if WIFI is ON on this API call.

Yes. When using Network Framework, take a look at requiredInterfaceType on NWConnection. For higher level APIs like URLSession, this would be an Enhancement Request.



Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

Dear

I do not need to have a client side and a server side and this do not help me reach my goal.

For using Alamofire or URLSession I would like to have an API run ONLY on Mobile Data even if WIFI is on for the purpose of Header Enrichment which means to give priority to the Mobile Data in this case.

Please Advice.

For using Alamofire or URLSession I would like to have an API run ONLY on Mobile Data

There is is currently no way to force a URLSession task to run over WWAN. If you’d like to see that change in the future, we encourage you to file an enhancement request.

Please post your bug number, just for the record.

Note Alamofire is based on URLSession, and so it has the same restrictions as URLSession.

for the purpose of Header Enrichment

Please explain what you mean by this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"