iOS VoIP 应用程序睡眠&可达性已更改,我可以收到通知吗?

发布于 2024-11-29 14:10:46 字数 214 浏览 5 评论 0原文

我正在为 iOS 构建一个 voip 应用程序,并且正在后台处理工作。

到目前为止,我让 iOS 在应用程序休眠时监听 voip 套接字,并根据传入数据唤醒它。

我的问题是:
当可达性发生变化时(Wifi -> 3G、Wifi -> 其他 Wifi 等)
并且应用程序已暂停,我可以收到一些通知以重新连接我的 voip 套接字吗?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简单 2024-12-06 14:10:46

答案既是“是”又是“否”:

  • 注册可达性网络更改通知。
  • 如果应用程序在其 voip 套接字(请参阅链接)连接时进入后台暂停状态,则在网络更改时应用程序将在后台唤醒 10 秒。
  • 如果应用程序在其 voip 套接字未连接时进入后台暂停状态,则网络更改时应用程序将不会唤醒。
  • 对于网络丢失和无连接进入后台的情况,解决方案可能是修复 Keep-Alive 块中的连接,您可以在 UIApplication 中安排该连接。
  • 注意:在上述 10 秒内,您可以请求后台任务以完成重新连接作业。

链接

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:

复古式 2024-12-06 14:10:46

如果您有后台套接字,您可以订阅可达性通知,它们将在后台触发,以便您可以对可达性更改执行操作。如果您在点击后台时没有取消订阅通知,并且订阅通知的对象是您的应用程序委托,那么您仍然会收到通知。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文