Apple Reachability Sample not running in the background

I saw that the forum has a lot of articles about the Apple Reachability Class, but I have not seen a solution for this.

I am developing a VoIP application that should detect connection changes in the background and in real time. The SCNetworkReachability API should do the job, but I have to face some problems ...

First of all, I downloaded the Reachability sample code from Apple (v2.2), but I was not able to get it to work in the background. It works great if I run the application on the simulator and plug in / unplug the network cable. But if I try on the device by launching the application, and then going into the background to enable / disable Wi-Fi, the application will not be notified at all.

I installed "The application does not start in the background = NO" and "Required background modes = The application provides voice over IP services" in the info file without success. Donoho's version of this test code has the same problem.

Secondly ... I included the Reachability code example in the VoIP application that I am developing (Linphone based), and ... connection changes are detected in the background ... !!!

However, it does not always work:

  • If I run the application with Wi-Fi, all of the following reachability changes, even in the background, will be detected → OK
  • but if I run the application without Wi-Fi, the application will not detect Wi-Fi recovery ... → KO

So the questions are:

  • How can I make an Apple Reachability sample in the background?
  • and ... when the Reachability class is running in the background, why does it only work when the first availability check detects that a connection is available?

I run applications on iPhone4 with iOS 5.1.1 (maybe some problems with iOS version> 5.0 ... ??)

I checked the solution too sharp on this topic , but the latest version of the Reachability sample already takes care of these save / release issues ...

Thank you in advance

+4
source share
2 answers

For several days I came across this problem, and finally, the problem seems to be closely related to the NSStreamNetworkServiceTypeVoIp connection mode.

It appears that a suspended application can only listen for connection changes after it has established an active NSStreamNetworkServiceTypeVoIp connection to the remote server.

This explains why the Reachability pattern does not respond to connection changes in the background (there is no NSStreamNetworkServiceTypeVoIp connection in the application) and why the voip application does not respond if Wi-Fi is disconnected the first time it starts ...

So, it looks like this will require some sort of workaround ...

0
source

This Reachability can help you, which also comes with sample code. It notifies you when your internet goes down or comes instantly.

-1
source

All Articles