iOS voip app sleeps & Reachability has changed, ca

2019-07-30 02:44发布

I'm building a voip app for iOS and I'm handling working at background.

So far, i have iOS listening to the voip socket while app sleeps and wake it uppon incoming data.

My question is:
When the reachability has changed (Wifi -> 3G, Wifi -> Other Wifi, etc)
and the app is suspended, can I get some notification in order to reconnect my voip socket?

Thanks.

2条回答
Deceive 欺骗
2楼-- · 2019-07-30 03:31

Answer was both Yes and No:

  • Register to Reachability network changes notifications.
  • If App goes to background suspended while its voip socket (see link) is connected, then uppon network changes app will wake up at background for 10 seconds.
  • If App goes to background suspended while its voip socket is NOT connected, then uppon network changes app will NOT wake up.
  • The solution for the scenario of network loss and going to background with no connection may be fixing the connection in the Keep-Alive block that you can schedule at UIApplication.
  • Note: during the mentioned 10 sec, you may ask for a background task in order to finish the reconnection job.

Links:

查看更多
再贱就再见
3楼-- · 2019-07-30 03:31

If you have a backgrounding socket you can subscribe to reachability notifications and they will fire while backgrounded so you can perform actions on the reachability changes. If you don't unsubscribe to the notifications when you hit the background you'll still get them if the object subscribing to the notifications is your app delegate.

查看更多
登录 后发表回答