iOS:在后台接收媒体

lyo*_*n72 5 voip udp pjsip ios4 ios5

我正在开发基于SIP和VoIP的iOS应用程序,并且要求应用程序应该在后台连续运行.我正在使用pjsip lib.

我知道要在bacground中运行iOS应用程序,我们需要这个

  • 使用voip值在Info.plist中设置UIBackgroundModes键

  • 创建了一个我传递给setKeepAliveTimeout的处理程序:handler:用于保持连接活动

但我只是希望如果我的应用程序在后台运行,我可以通过(RTP/RTCP)接收UDP数据包,而我保持UDP端口始终打开.

我已经完成了这些帖子:

但是,我还没有清楚地意识到,即使应用程序处于后台或前台,我们也可以连续获取UDP数据包.

因此,如果iOS客户端应用程序中有任何数据,应用程序应该能够通知用户.

请给出建议.

Sha*_*K M -1

我认为您可以在应用程序在后台运行时设置本地通知,并通过通知指示来电的用户。当用户进入应用程序时,您可以显示来电。

在下面的链接中,检查 后台执行和多任务处理以及安排本地通知的传送

IE 由于您已在 Info.plist 中设置了 UIBackgroundModes 键,因此您的应用程序将支持长时间运行的任务。因此,在 applicationDidEnterBackground 方法中添加一个方法,该方法在有呼叫时创建 UILocalNotification。UILocalNotifications 使用警报消息和您选择的音调通知用户。因此,一旦用户收到通知并且用户进入应用程序,应用程序将进入前台,您可以在其中添加让他接听电话的方法。

在 LocalNotification 的警报正文中,您可以将呼叫者的信息发送给用户。

编辑: 查看Paul Richter在此链接中的回答,他说

VOIP mode gives you the ability to have code running to notify you of a call coming in
 but you're not going to be able to record audio from the background. If you look at how
Voip apps work, when a call comes in a Local Notification is sent informing the user 
that a call is coming in. The User then must accept the call which will bring the 
application to the foreground at which point from the audio side of things you can 
activate your session and proceed with the phone call. 
Run Code Online (Sandbox Code Playgroud)

尽管与您正在使用的库不完全相关,但他对该过程给出了很好的解释。

希望这可以帮助。