I'm using a VOiP Socket in my iPhone application. I manage to get it working properly, both in background mode, or when the application is in the foreground.
My issue is at iPhone startup: how to be sure that the iPhone has network access (3G or wifi) in order to properly connect the socket without bothering the user ?
Details: a VOiP application is supposed to be started automatically as soon as the iPhone starts : this is working ok, the didFinishLaunching
is invoked right after the iPhone startups. But at this time, the user may not have entered his pin code (so that 3G isn't available) and wifi may not be available.
Is there any technique to start
automatically the VOiP Socket when network access is ok ?
My current approach that fails : in the didFinishLaunching
I keep on trying to start the VOiP socket every 5 secs. If it takes too long without managing to get the connection, the OS is going to kill the app, (max 20s to start), but as the app is flagged as "VOiP", it's going to be started again, and so on...
After a while, once network is OK, the socket is being created , connected and everything seems to works ok, EXCEPT that when data comes to the socket, my callback didReceivedData
is not invoked (I display a local notification as soon as I get something from the socket for debug purpose) .
Then, if I start the application just 1 time, and then quit it (home button), so that the application is put in the background, in that case, the socket callback is properly invoked and I see local notifications being displayed, proof that the socket is properly waken up in that case.
I would like to get the VOiP socket up and running right from iPhone startup (once network is OK) without having the user to launch the application 1 time. Any idea about how to achieve this ?