iOS voip app sleeps & Reachability has changed, can I get notification?

≡放荡痞女 提交于 2019-12-11 13:35:00

问题


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.


回答1:


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:

  • VoIP socket in iOS
  • VoIP socket wakeups - iOS 5 Watchdog



回答2:


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.



来源:https://stackoverflow.com/questions/7080393/ios-voip-app-sleeps-reachability-has-changed-can-i-get-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!