简体   繁体   English

在iPhone上强制进行WWAN连接,即使可以使用Wi-Fi也是如此

[英]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. 我需要在iPhone上通过WWAN(即移动网络)建立网络连接,即使设备连接到Wi-Fi网络,但我找不到办法。

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. 我已尝试进入套接字级别并迭代可用接口,但是当连接到Wi-Fi时,WWAN接口(pdp_ip0)消失。

The solution needs to be App Store safe. 解决方案需要App Store安全。

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. 枚举网络接口,您将看到当您在wifi和3g上连接时,有2个具有不同的本地IP地址。 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. 也许你可以使用Reachability代码来确定是否启用了Wi-Fi,启动UIAlertView以警告用户退出应用程序,打开Settings应用程序并手动关闭无线。 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." 您需要告诉用户关闭WiFi连接,因为“这是应用程序需要连接的服务的不可协商的操作要求。”

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. 在这种情况下,如果您清楚他们为什么必须禁用WiFi,则用户不太可能通过不良评价来杀死您。

-t -t

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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