0

Here's the link to the app...

http://www.gadgetlite.com/2011/01/25/viber-app-hits-version-1-1-network/

enter image description here

I've looked around and mostly suggest private api or networkactivityindicator (which is not what im looking for)

Would appreciate any hint on how I could start

Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
Mickey Cheong
  • 2,980
  • 6
  • 38
  • 50

3 Answers3

1

The network quality of the Viber app refers to the data connection.

Set a start time at NSURLConnectionDataDelegate's connection:didReceiveResponse:, then transmit something and count the bytes at connection:didReceiveData:. At connectionDidFinishLoading: set the finish time, calculate the time interval and match that against your arbitrary thresholds.

Jano
  • 62,815
  • 21
  • 164
  • 192
1

I have the feeling a default iOS framework would have that information (look at networking libraries in iOS). If not, you could possibly look at ping times (ping a URL in the background and look at the delay amount, make sure you're using a server that's available and quick at all times. ping google.com maybe?)

Ege Akpinar
  • 3,266
  • 1
  • 23
  • 29
  • I really like this answer, the only question at the back of my mind is whether checking the ping will use a lot of resources. Do you have an optimised way of doing this? Otherwise a great idea! – Septronic Aug 05 '15 at 02:06
  • Not really, you are already doing VoIP, sending voice packets with high frequency. Hence, a ping every second or so won't make much difference. I need to add that idea of pinging Google was mistake, you want to display connection to your servers so you should ping your own service and compare response time against expectations. – Ege Akpinar Aug 05 '15 at 09:51
  • A slightly lighter method could be to keep a connection open and receive continuous data (server must be capable of sending stream of data, e.g. 1 byte every second). This will be lighter because it saves creating a new packet every time, which has its overheads (packet header, opening a new connection, handshake, etc.) – Ege Akpinar Aug 05 '15 at 09:53
0

So I looked around, having read the very useful answer that Ege Akpinar gave earlier, and stumbled upon this article. They use the Apple's own Class, which can be used on Mac OSX and iOS:

Get ping latency from host

The link to Apple's Sample is available through the above link, but for the sake of efficiency and speed, here is its direct link:

https://developer.apple.com/library/mac/samplecode/SimplePing/Introduction/Intro.html#//apple_ref/doc/uid/DTS10000716-Intro-DontLinkElementID_2

I also found another post that shows how to implement the class using Swift. I thought I might include it, in case you are using Swift:

Using Simple Ping in swift (iOS)

I hope this will be of some use.

Community
  • 1
  • 1
Septronic
  • 1,156
  • 13
  • 32