首页 > 解决方案 > 后台套接字调用 - iOS - Swift

问题描述

当我的应用程序进入后台时,它停止通过套接字接收消息,有没有办法让套接字在后台工作,我已经在 .plist 中启用了后台模式。

或者其他任何替代方案,如果我们无法在后台接收套接字消息?

我正在尝试为 iOS 制作聊天解决方案并使用 soket.io 框架。

标签: iosswiftsockets

解决方案


When app goes into the background, the handshake between server and sockets will broke out. So we can't get data from server anymore.

I suggest you to use Push Notifications to update data on the app side. you can use Notifications delegate to get the payload from the notification.

There is an another solution, you can handle a check for each message on server side, if it is received on the client side or not. If it is not received on that application side it means application is in background or killed state. So when ever the application will become active again and sockets get connected to the server, then make a call to get those messages which were sent when application was in background/killed state.


推荐阅读