OGeek|极客世界-中国程序员成长平台

标题: ios - 套接字在后台状态 iOS [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:53
标题: ios - 套接字在后台状态 iOS

也许有人在应用程序处于后台时解决了与服务器的稳定连接问题?我需要将音频数据从服务器传输到客户端应用程序。 我知道 iOS 的所有黑客如何让应用程序保持事件状态,但我需要合法的方法来解决这个问题。也许你有什么想法? 我发现我可以向设备发送 VoIP 推送,该设备将唤醒我的应用程序,然后建立到我的服务器的 tcp 连接,但这个套接字将保持事件约 30 秒(正如我在日志中看到的那样,每 3 秒在发送的 iOS 应用程序中触发计时器数据到服务器)这对我来说还不够。



Best Answer-推荐答案


也许这个项目https://github.com/SmallSharpToolsOpenSource/Speakerbox会对某人有所帮助。 还有这个视频https://www.youtube.com/watch?v=lXJ1LDjL4Os

以及来自 Apple 技术支持的官方回答:

PushKit is how voip apps can reliable receive silent notifications, while CallKit is basically a UI framework voip apps can use to notify the user about calls. Note that there is NOT any direct connection within the APIs- for example, a voip app can generate a local notification (instead of using CallKit) or simply do nothing and “ignore” the notification entirely. Similarly, a voip app could “fake” a call at anytime by simply telling CallKit that there was an incoming call (our sample code for CallKit did exactly this).

Anything your app could previously have done when it received voip socket traffic, it could also do when it received a PushKit notification.

Standard voip apps actually operate in two COMPETELY unrelated “modes”:

1) While waiting for an incoming call, the app is suspended until “something” (PushKit OR a voip socket) wakes the app to tell it about the call.

2) Once a call has started, the app has an active audio session and is relying an the standard “background audio” behavior of iOS, just like a wide variety of other audio apps (for example, any streaming music app).

关于ios - 套接字在后台状态 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53535146/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4