how to hook ios connection changes - ios

I'm working on a VOIP project.
My app uses reachability to listen when the connection changes and to re-register with SIP SERVER. Everything works well when the app is in the foreground.
But when My App enters the background, it can't catch connection changes. At least 10 minutes later (when keepAlive runs) my app can check the connection again.
I intend to look at connection changes (lost wifi, 3G change to wifi, wifi to 3G, ...) using a private framework and mobile substrate. I've tried many methods but have not found a working one yet.
Does anyone know which method will be called when connection changes ?
Thank you

i think only Reachability class is better for this even apple use this class for his code please see this Link in this code you find. you answer some how

I found a question from someone going through a similar scenario:
How to get Reachability Notifications in iOS in Background when dropping Wi-Fi network?
Hope this helps.

Make sure your app is setup to do VoIP in the background. In your Info.plist file. Add the following key value pair:
See also: https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html

Related

iOS Backgrounding mode Location Updates - but also keep a socket open

I have a navigation application that works with both CoreLocation (Backgrounding mode Location updates) as well as GPS data provided over a UDP connection from an external sensor.
I've noticed that when I background the app the socket goes down (which likely makes sense).
What is the procedure to keep the socket open in backgorunding?
Idea
I thought perhaps to register as a VoIP app - would keep the socket open but it looks like that works differently now.
The documentation suggest implementing setKeepAliveTimeout:handler: but this appears to be deprecated.
I'm not sure exactly how to proceed. Any ideas? The best I can come up with is a hack to have my location-update handler run a check on the socket so see if there is new data - but I'm assume there is a legitimate way to do this.
When the phone goes in stand-by all the UDP socket are closed and only TCP connection can be used. Yes probably with VOIP app you can use the UDP but in that case your app will be reject because your don't use a real VOIP service. I had the same problem ... In my case, even if the phone is in background, I want to send UDP message to a domotic system but is not possible.

Reachability code not working accurately in ios

In my application i want to check server accessibility before going to the next screen when a button is tapped.
I have used tony million reachability and AFNetworking reachability, they are all working fine. But the issue is when i turned off my wifi, it is taking 10 secs time to reflect the same in iPad, meantime if i check the server connectivity it is showing that server is reachable (i am using iPadAir and it is not connected to Mobile Data). After iPad is detecting that wifi is switched off only it is giving not reachable. i even tried with apple simple ping example, still i am getting the same issue.
Please advice
Run reachability function viewdidload and save value. Use this value buttonPress event and in buttonPress event Run reachability function on background again.
Finally i found a solution
Please go through this website
SimplePingHelper is written on top of SimplePing and is very easy to use
Thanks

Obtaining Wifi connectivity notification while in background

Is it possible to get notifications about Wifi connectivity state while an iOS app is running in the background? It is looking like a no, but I am also curious if this could be checked during a background fetch routine.
You have limited options to get processor time while in background and as far as I know there is no direct option to be notified on the WiFi status. Here you can find the modes of background execution: apple docs
I have tried with VOIP support to keep a stream opened while the app was in background. Everything worked ok and I was getting connectivity errors when the connection was lost, also I was able to try to reconnect from time to time until the connection was back on.
The only problem is that Apple will not approve the app unless your app provides a VOIP functionality (although the first two versions of the app were approved and only on the third one it got rejected because of flagging VOIP but not actually providing it).
I hope this helps.

iOS VOIP app does not accept new socket connections in background

I am trying to implement an iOS VOIP application.
I am using GCDAsyncSocket to listen on a port for connections. I did add the required background modes in info.plist and also registered the readstream and writestream to kcfNetworkServiceTypeVOIP.
I also added KeepAliveTimeOutHandler to wake up the app. The handler block just prints the wake up time to stdout.
As long as app is in foreground new connections are accepted but when the app is in background, the app is not waken and all the connections attempted are sent to the socket when the app moves to foreground again.
I searched through many solutions but could not get it to work.
Thanks in advance.
I am not sure if it is still relevant for you but in case someone else reads this question.
As discussed in other similar question on stackoverflow in this one for example you can have only one socket which is in NetworkServiceTypeVOIP mode. Otherwise both of them will not work and your app will not wake up and not accept new connections.

Detecting Whether an iPhone has roamed from wifi to 3G or vice versa

G'day Guys,
I've been using the reachability API with reachability status callbacks to determine whether an application is connected over 3G or wifi. It's an application that acts as a voice extension for an existing piece of hardware and as such we're using the VoIP APIs to run in the background and accept calls etc.
Is there a definitive way other than using reachability status callbacks to determine whether you can access a particular IP endpoint or not? I could use an ASIHTTPRequest and then check if it timed out but that may cause potential problems for me in the long run.
I'm not looking for a programmatical answer but more any insights other developers would have on how to manage a roaming between the two in the background if you have a persistent connection. Basically if the device roams over to 3G I need to destroy the session on the device and if it roams back over to Wifi I need to recreate the session.
Any feedback or advice would be welcome.
The Reachability APIs will provide the connection change notifications to your app so that you can know when the connectivity changed from WWAN to wifi. It will not tell you if you've changed from Edge to 3G or LTE unfortunately. The Reachability API also has methods to test reachability to a specific host. So, in your app you can listen for the notifications that the connection method has changed, then when it does change test reachability to your target host and at that time make the decision whether to rebuild the session or leave it intact.

Resources