0

我需要在我正在开发的 iPhone 应用程序中通过 WiFi 连接来推广 3G/GPRS。请让我知道这是否可行,如果可以,如何?

问题是当我有一个可用且已连接但未使用 Captive Portal 登录的 WiFi 网络时,我无法使用该 WiFi 网络执行需要 Internet 连接的任务。我注意到的是 Reachability API 检测到可用的 WiFi 但我无法使用它,因为我没有登录,所以在我登录之前我没有使用这个 WiFi 热点连接到互联网。所以我想使用 3G/GPRS 来执行需要互联网连接的任务。

iPhone 的默认行为是在可用时使用 WiFi,如果不可用则仅使用 3G/GPRS。

所以请让我知道 3G/GPRS 和 WiFi 是否都可用,但我不是使用 WiFi 而是 3G/GPRS 连接到互联网,如何使用 3G/GRPS 来执行需要互联网连接的任务。

问候,

4

3 回答 3

0

Third-party applications don't get control of where their data comes from. About all you're going to be able to do is ask your users to turn wifi off while your application does its thing. If you need to get back onto wifi after doing the initial data transfer, you could make some clever use of the iOS 4 multitasking and local-notification APIs: when your application enters the background, it could start a background-task handler (using -beginBackgroundTaskWithExpirationHandler: in your app delegate's -applicationDidEnterBackground:) to wait for the wifi connection to become unavailable, do its thing with the cell network, then create a UILocalNotification to tell the user it's okay to turn wifi back on again. That way, the user could get the benefits of whatever your app does and still keep the connection they started out on.

于 2010-06-24T16:50:19.620 回答
0

出于安全原因,Apple 不允许开发人员以编程方式进行此类设置,尽管您通过 GPRS 网络连接来实现某些目的。

于 2013-04-01T00:48:15.293 回答
0

如果您正在创建一个需要访问某些网络资源才能运行的应用程序,那么您应该直接 ping 或尝试直接连接到这些资源,而不是仅仅依赖于可访问性来做出决定。如果您无法 ping 您的服务器,则让应用程序执行与可访问性报告零连接性相同的操作(即使它可能不是)。

于 2010-09-01T05:35:51.413 回答