简体   繁体   English

iPhone SDK 4.x-后台模式下的网络可达性回调

[英]iPhone SDK 4.x - network reachability callback in the background mode

In our iPhone application we have a situation when the current network is lost (Wi-Fi) and we need to switch to another network (GPRS). 在我们的iPhone应用程序中,当当前网络丢失(Wi-Fi)时,我们需要切换到另一个网络(GPRS)。

We're handling this situation using Reachability API of iPhone SDK 4.x 我们正在使用iPhone SDK 4.x的Reachability API处理这种情况

Everything works fine, except the background mode - reachability callback is not being invoked in the background mode. 除后台模式外,其他一切正常,在后台模式下未调用可达性回调。

Does anyone know the solution to this problem? 有人知道解决这个问题的方法吗? How to handle the lost connections in the background mode? 如何在后台模式下处理丢失的连接?

Please note - we're using "VoIP" flag for the background mode and the keep-alive timer with 600 seconds period. 请注意-我们在后台模式下使用“ VoIP”标志,并使用持续时间为600秒的计时器。 So our application responds to all incoming calls in the background mode + sends successfully SIP REGISTER messages every 600 seconds as well. 因此,我们的应用程序在后台模式下响应所有来电,并且每600秒也成功发送一次SI​​P REGISTER消息。

The only remaining problem is about the re-connections upon the network change in the background mode. 唯一剩下的问题是在后台模式下网络更改时的重新连接。 Reachability callback does not help to listen to such kind of changes. 可达性回调无助于侦听此类更改。 And waiting until the next cycle of background timer (up to 600 seconds) is not acceptable, because the user won't be able to accept any incoming calls during this period. 而且,等待到下一个后台计时器周期(最长600秒)是不可接受的,因为在此期间用户将无法接听任何来电。

Please advise. 请指教。

我认为您还应该在AppDelegate的applicationDidEnterBackgroundapplicationWillEnterForeground方法中检查可到达性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM