即使 Wi-Fi 可用,也强制 iPhone 上的 WWAN 连接
我需要在 iPhone 上通过 WWAN(即移动网络)建立网络连接,即使设备已连接到 Wi-Fi 网络,但我找不到执行此操作的方法。
我尝试深入到套接字级别并迭代可用接口,但是当连接到 Wi-Fi 时,WWAN 接口 (pdp_ip0) 消失。
该解决方案需要是 App Store 安全的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
枚举网络接口,您将看到当您同时连接 wifi 和 3g 时,有 2 个具有不同的本地 IP 地址。在发送数据之前,您可以通过在正确的接口上强制绑定套接字来使用其中一种。尝试找到最佳接口来路由数据包的内核应该对您的选择感到满意。
免责声明:我没有尝试过,这只是一个建议。
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.
也许您可以使用 可达性 代码来确定 Wi-Fi 是否已启用,触发
UIAlertView
警告用户退出应用程序、打开“设置”应用程序并手动关闭无线。绝对不理想。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.没有受支持的方法可以执行此操作。您需要告诉用户关闭 WiFi 连接,因为“对于应用程序需要连接的服务来说,这是不可协商的操作要求”。
在这种情况下,如果你清楚为什么他们必须禁用 WiFi,用户不太可能用差评来杀掉你。
-t
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