IOS 如果应用程序处于后台状态,则不会触发实时更新

IOS Real time updates won't trigger if app is in background state

我使用 nes 在我的 hapi 服务器中设置了 websocket 支持

在 android 上试过了,到目前为止,即使在后台状态下,实时更新仍然有效。

问题出在IOS,当您的应用程序处于后台状态时,不会触发实时更新。我怎样才能使这项工作

iOS 只允许您的 app to keep running in the background in some specific cases. Keeping the WebSocket connection is not one of them. In order to achieve this realtime update, your server needs to provide an API which allows the app to fetch the new data, and your app needs to register a background task and do the fetch. For more detail, you can check the link here