setKeepAliveTimeout iOS 行为,在 300 秒内超过 15 次唤醒 [英] setKeepAliveTimeout iOS behavior, exceeded 15 wakes in 300 sec

查看:46
本文介绍了setKeepAliveTimeout iOS 行为,在 300 秒内超过 15 次唤醒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 iOS 5 上编写 VOIP 应用程序,我试图了解实际通信如何在后台保持活动状态.

I am writing a VOIP application on iOS 5 and I am trying to understand how the actual communication can stay alive while in the background.

我知道套接字在单位时间内可以获得的最大唤醒次数.我的问题是我的套接字连接收到太多唤醒消息,因为应用程序因崩溃消息而终止:

I understand there is a maximum amount of wakes the socket can get per amount of time. My problem is that my socket connection receive too many wakes messages, because of that the app is terminated with crash message:

在 300 秒内超过 15 次唤醒

exceeded 15 wakes in 300 sec

我真正不明白的是,如果每段时间可以接收的数据量有限制,那么套接字应该如何通过它不断发送和接收数据(用于 VOIP 需求)?

What I really don't understand is how is the socket supposed to be able to constantly send and receive data through it (for VOIP needs) if there is a limit for the amount of data it can receive per amount of time?

假设套接字正在接收在后台进行的语音对话的语音数据.语音数据不是应该通过套接字连接吗?如果是这样,如果套接字在单位时间内可以进行的活动有限制,它如何工作?

Let's say the socket is receiving voice data for a voice conversation that is happening while in the background. Is it not that voice data supposed to go through the socket connection? If so, how can it work if there is a limit for the activity the socket can have per amount of time?

推荐答案

后台 VOIP 应用行为(iOS 4.0+):

  • 有一个保持打开的套接字,标记为 Voip
  • 这个 VOIP socket 由系统维护,而 app 挂在 BG
  • 你可以安排一个keep-alive块,操作系统会每X次唤醒你的应用程序
  • X >= 10 分钟(见 [[UIApplication sharedApplication] setKeepAliveTimeout: handler:)
  • 此套接字不是媒体套接字,它仅用于接收来电邀请
  • 应用程序唤醒套接字上的每个传入数据(iOS 5.0+ 限制为 300 秒内 15 次)
  • 收到来电后,您的应用将被唤醒,您可以为此通话打开音频会话.

    VOIP app behavior at background (iOS 4.0+):

  • Having a single socket that remains open, flagged as Voip
  • This VOIP socket is maintained by the system, while app suspended at BG
  • You may schedule a keep-alive block, and the OS will wake your app every X time
  • X >= 10min (See [[UIApplication sharedApplication] setKeepAliveTimeout: handler:)
  • this socket is NOT the media socket, it uses only to receive invitations for incoming calls
  • App wake up on every incoming data on the socket (iOS 5.0+ limit is 15 times in 300 seconds)
  • Once you've received an incoming call, your app will wake up, and you may open an Audio Session for this call.

    VOIP 应用程序应在 info.plist 中的必需的后台模式"下进行标记,作为语音"&音频".

    VOIP apps should be flagged at info.plist, under "Required background modes", as "voip" & "audio".

    打开音频会话后(用于主动呼叫),您的应用程序可能会在后台完全运行并且不再暂停,直到此音频会话关闭.

    无论如何,另一种选择是使用推送通知作为来电的触发器.
    此外,这将为您省去 24/7 全天候维护插座的麻烦,节省一些电池,
    并且即使用户关闭了应用程序也能工作(第一种选择不是这种情况).

    Anyway, the other alternative, is to use Push notifications as triggers for incoming calls.
    Also, this will save you the trouble of maintaining a socket 24/7, save some battery,
    and will work even if the user has closed the app (which is not the case with the first alternative).

    这篇关于setKeepAliveTimeout iOS 行为,在 300 秒内超过 15 次唤醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆