iOS XMPP 在后台断开连接不会被报告

发布于 2024-12-15 04:48:43 字数 208 浏览 6 评论 0原文

当应用程序在后台运行并且 xmpp 由于互联网中断而断开连接时,如果互联网恢复正常,当我打开应用程序时,不会进行断开连接调用,因此应用程序不会尝试重新连接。

如果我检查 xmppstream 是否已连接,它显示为“是”。当我返回应用程序时,如何检查连接是否仍然有效?

目前我正在尝试断开连接,并在每次应用程序唤醒时连接。但理想的是检测断开连接...

谢谢

When the app is in the background and xmpp disconnects because the internet goes down, and if the internet comes back up, when I open the app, the disconnect call is not made so the app doesn't try to reconnect.

If i check the xmppstream is connected it shows as Yes. How can I check if the connection is still alive when I go back to the app?

Currently I am trying a disconnect, and connect each time the app wakes up. But ideal would be to detect disconnection...

Thanks

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

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

发布评论

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

评论(2

浅听莫相离 2024-12-22 04:48:43

如果您可以检测到应用程序何时唤醒,请发送 ping。如果没有收到回复,请重新连接。如果您使用的 XMPP 库支持流管理,特别是流恢复支持,您可以用它来拾取流。

更好的解决方案是使用一个单独的守护进程来管理连接,并在后台保持活动状态(如果 iOS 允许的话)。另外,这个 XEP 可能会引起兴趣。

If you can detect when the app wakes up, then send a ping. If you don't get a reply, reconnect. If the XMPP lib you use has support for Stream Management, especially the stream resumption support, you could use that to pick up the stream.

A better solution would be to have a separate daemon that manages the connection, and stays alive in the background, if that's even allowed on iOS. Also, this XEP might be of interest.

安穩 2024-12-22 04:48:43

如果您使用的是 XMPPFramework (https://github.com/robbiehanson/XMPPFramework),那么请查看 XMPPReconnect,这将为您省去很多重新连接的麻烦。

创建流后,使用以下命令。

xmppReconnect = [[XMPPReconnect alloc] init];
[xmppReconnect activate:xmppStream];
[xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];

If you're using XMPPFramework (https://github.com/robbiehanson/XMPPFramework), then take a look at XMPPReconnect, which will save you a lot of the hassle of reconnecting.

After the stream has been created, use the following.

xmppReconnect = [[XMPPReconnect alloc] init];
[xmppReconnect activate:xmppStream];
[xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文