4

I've seen that there's a lot of entries in the forum about Apple's Reachability Class, but I haven't seen a solution for this one.

I'm developing a VoIP app that needs to detect connectivity changes in background mode and real time. SCNetworkReachability API should do the job, but I'm facing some problems...

First of all, I've downloaded Reachability sample code from Apple (v2.2) but I haven't been able to make it work in background mode. It works great if I launch the app on the simulator and plug/unplug de network cable. But if I try on the device, launching the app and then going to background mode for enable/disable wifi, the app isn't been notified at all.

I've set "Application does not run in background = NO" and "Required background modes=App provides Voice over IP services" in the info.plist without success. The Donoho version of this sample code has the same problem.

Second one... I've integrated the Reachability sample code on the VoIP app that I'm developing (Linphone based) and... the connectivity changes are detected on background mode...!!!

Nevertheless, it doesn't work well always:

  • if I launch the app with wifi on, all the following reachability changes, even in background mode, are detected -> OK
  • but if I launch the app without wifi off, the app doesn't detect the wifi recovery... -> KO

So, the questions are:

  • how can I make Apple Reachability sample works in background mode?
  • and... when Reachability class looks to be working on background mode, why it only works really when the first reachability check finds connection available?

I'm running the apps on iPhone4 with iOS 5.1.1 (maybe some problem with iOS version > 5.0...??)

I've checked too the pointed solution on this thread, but last version of Reachability sample is already taking care of that retain/release issues...

Thanks in advance

Community
  • 1
  • 1
torino
  • 51
  • 4
  • did you get any solution for this. I am also facing the same issue.. looking out for a solution – CKT Feb 14 '18 at 09:28

2 Answers2

0

I've been around this issue for some days, and finally the problem looks to be closely related with the NSStreamNetworkServiceTypeVoIp connection mode,

Looks like a suspended app only could listen to connectivity changes once it has established an active NSStreamNetworkServiceTypeVoIp connection with the remote server.

That explains why Reachability sample is not responding to the connectivity changes in background mode (no NSStreamNetworkServiceTypeVoIp connection within the app) and why the voip app neither responds if wifi's off on first launch...

So, looks like some kind of workaround will be needed for this one...

torino
  • 51
  • 4
-1

This Reachability may help you which also comes with sample code.This notifies you whenever your internet goes down or comes up instantly.

Shantanu
  • 3,086
  • 3
  • 25
  • 32
  • Thanks Shantanu, but this sample code is exactly the one I'm testing without success. I'm testing the code without any changes so I can't explain why it isn't working as expected on background mode... – torino Jul 03 '12 at 07:14