检查iOS的慢速互联网连接 [英] Check for slow internet connection iOS

查看:98
本文介绍了检查iOS的慢速互联网连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了apple提供的Reachability类,它可以正常检查互联网连接。我的应用程序显示消息,如果互联网熄灭。

I have added Reachability classes provided by apple and it is working fine for checking internet connection. MY app is displaying message if internet goes off.

但如果互联网非常慢,它只是继续加载.......

But if internet is very slow it just keep loading.......

我正在使用wi-fi,当iPhone通知栏中只有一个点可以看到wifi信号时,我遇到了这个问题。

I am using wi-fi and I face this problem when there is only a dot visible in iPhone notification bar for wifi signal.

所以我我想知道如何检查网络连接是否缓慢。

So I want to know how can I check for slow internet connection.

推荐答案

您可以向您的服务器发送请求,并且它是关于您希望返回5-10 KB的数据,然后创建一个计划为20秒的计时器回调。

You can send a request to your server and given that it's about 5-10 KB of data you expect to be returned, then create a timer callback that is scheduled for say 20 seconds.

如果您未在20秒内收到回复秒,然后让我们考虑一个缓慢的连接。

If you don't get a response within 20 seconds, then let's consider that a slow connection.

示例:

// make POST request to server, the POST request should have a callback method assigned
[self testSpeed];

// schedule a method to be called after 20 seconds
myTimer = [NSTimer scheduledTimerWithInterval:20.0 selector:@selector(stopSpeedTest) .... ];

// your POST request callback method
-(void)speedTestCallback
{
    [myTimer invalidate];
    myTimer = nil;

    [self alertGoodSpeed];
}

// your stopSpeedTest method to identify app didn't receive response within 20 seconds
-(void)stopSpeedTest
{
    [self alertTooSlow];
}

我认为这就是H2CO3试图提出的问题:

I think that's what H2CO3 was trying to ask:

你认为每秒有多少字节慢?

"How many bytes per second do you consider slow?"

你需要决定用户是否愿意等待多久对于预期返回的数据量。

You need to decided on long you think the user is willing to wait for the amount of data expected to be returned.

如果你告诉用户你正在下载50 MB的数据,那么是的,让他们全部回到20第二个是快速的。

If you're telling the user you're downloading 50 MB of data, then yes, getting them all back in 20 second is fast.

然而,如果你只想要5-10 KB的数据并且花费的时间超过10秒,更不用说20秒,那么连接非常慢。

However, if you're expecting only 5-10 KB of data and it's taking longer than 10 seconds, let alone 20 seconds, then connection is very slow.

这篇关于检查iOS的慢速互联网连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆