views:

437

answers:

3

I need to make a network connection over WWAN (i.e. the mobile network) on an iPhone, even when the device is connected to a Wi-Fi network, however I can't find a way to do this.

I've tried going down to the socket level and iterating through the available interfaces, however when connected to Wi-Fi, the WWAN interface (pdp_ip0) disappears.

The solution needs to be App Store safe.

+2  A: 

Perhaps you can use the Reachability code to determine if Wi-Fi is enabled, firing a UIAlertView to warn the users to quit the app, open the Settings app and switch off wireless manually. Not ideal, definitely.

Alex Reynolds
Yes - I've been looking at the Reachability code. The problem is, requiring users to switch off Wi-Fi is the sort of thing that gets an app a flood of 1 star reviews in the App Store.
Andrew Ebling
I hear you. Hope you find an answer -- I'm curious about this, myself.
Alex Reynolds
A: 

There is no supported way to to do this. You need to tell the user to turn off the WiFi connection since "It's a non-negotiable operational requirement for the service the app needs to connect to."

In this scenario, the user is not likely to kill you with bad reviews if you are clear about why they have to disable WiFi.

-t

Tim
A: 

Enumerate the network interfaces, you will see that when you're connected on both wifi and 3g, there are 2 with different local ip addresses. You might be able to use one vs the other by forcing a bind of your socket on the right interface before sending the data. The kernel which tries to find the best interface to route your packet should be happy with your choice. Disclaimer: I have not tried this, this is just a suggestion.

c0diq