iPhone 上是否强制要求提供有关状态更改的网络可达性通知?

发布于 2024-11-05 05:04:22 字数 318 浏览 0 评论 0原文

许多可达性测试代码似乎都包含“通知”概念,以便当网络恢复时,用户可以收到通知。

  1. 我需要实现“通知”部分吗?每当用户尝试需要网络连接但网络连接不可用时提醒用户是否可以接受? (连接恢复时没有通知)

  2. 我看到示例代码处理纯网络可用性(如果设备连接到 wifi、3g 等)以及特定 IP 的可达性。我的应用程序需要在适当的时候连接到特定的 IP 地址。在这种情况下,只需在适当的时间无法访问该 ip 时发出警报即可,还是我需要处理更多内容?(例如放置不同的消息来提醒用户打开网络并提醒用户我的 ip 无法访问)可达)

谢谢

Many reachability test codes seem to incorporate "notify" concept so that when network gets back on, user can get notified.

  1. Do I need to implement the "notification" part? Is it acceptable to alert user whenever he tries something that needs network connection and it is not available? (without notification when connection gets back)

  2. I see example codes deals with pure network availability(if the device is connected to wifi, 3g, and so on) and with reachability to specific ip. My app needs to connect to specific ip address when appropriate. In this scenario, just alerting if that ip is not reachable in appropriate times are all that's required or do I need to handle something more?(such as putting different messages for alerting user to turn on network and for alerting user that my ip is not reachable)

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤者何惧 2024-11-12 05:04:22

1.
我建议您查看 Andrew Donoho 的 Reachability 类,它是 Apple 发布的示例的扩展:

http ://blog.ddg.com/?p=24

这将消除处理通知的需要,并允许您专注于简单地测试您的 IP 的可达性或某种网络类型是否可用积极的。

2.
就向用户的实际通知而言,我想说这取决于您的应用程序。例如,在我的一个应用程序的绝大多数屏幕上,UIView 尝试在加载该视图时从 RESTful 服务异步下载数据。我事先不进行任何可达性测试,我只是尝试拨打电话,如果请求失败,我会在事后通知用户。除非您有特定情况需要知道 IP 是否可达,否则我认为在一般情况下处理连接尝试中的任何错误就足够了。我确信有很多边缘情况,但您可能想首先测试可达性。

另一方面,我确实使用了给定屏幕上的可达性,建议使用 WiFi 连接。由于该屏幕执行相当数据密集型的同步,因此我警告用户,如果他们使用 3G,则与 WiFi 仅执行同步相比,同步需要更长的时间。

1.
I'd recommend taking a look at Andrew Donoho's Reachability class that is an extension of the sample released by Apple:

http://blog.ddg.com/?p=24

That'll abstract away the need to worry about handling the notifications and allow you to focus on simply testing the reachability of your IP or if a certain network type is active.

2.
In terms to actual notification to the user, I'd say that depends on your application. For instance on the vast majority of the screens on one of my Apps the UIView attempts to do an async download of data from a RESTful service when that view loads. I don't do any reachability tests beforehand, I simply attempt to make the call and if the request fails, I notify the user after the fact. Unless you have a specific case of needing to know an IP is reachable, I'd think in the general case handling any errors on connections attempts should be sufficient. I'm sure there are are plenty of edge cases though that you might want to test reachability first.

On the other hand I do use the reachability on a given screen that I recommend a WiFi connection. Since that screen performs a fairly data intensive sync, I warn the user if they are on 3G that the sync make take quite a bit longer vs. WiFi simply performs the sync.

最近可好 2024-11-12 05:04:22
  1. 据我所知,没有要求您在网络可用时弹出通知,或者实际上在网络不可用时弹出通知。您可以改为启用/禁用与网络相关的按钮(只要用户知道按钮被禁用的原因)、显示不显眼的屏幕指示器或其他任何内容。

    重要的是,当网络不可用时,您不会显示空白屏幕或神秘的错误消息,否则会让用户想知道为什么事情不起作用。

  2. 我不知道您有任何区分“网络关闭”和“网络打开但 IP 地址无法访问”的要求。

  1. AFAIK, there is no requirement that you pop up a notification when the network becomes available, or in fact that you actually pop up a notification when the network is not available. You could instead enable/disable network-related buttons (as long as the user can know why the buttons are disabled), display an unobtrusive on-screen indicator, or whatever.

    The important part is that you do not display a blank screen or a cryptic error message when the network is not available, or otherwise leave the user wondering why things aren't working.

  2. I don't know of any requirement that you differentiate between "networking off" and "networking on but IP address unreachable".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文