简体   繁体   中英

Forcing a WWAN connection on iPhone, even when Wi-Fi is available

I need to make a network connection over WWAN (ie 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.

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM