5

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

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

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

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

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

我已经浏览了这些帖子:

但是,我还不清楚即使应用程序在后台或前台,我们是否可以连续获取 UDP 数据包。

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

请提出建议。

4

2 回答 2

0

为了在后台运行 VoIP 应用程序并在服务器上注册,应该在 iOS 上使用 TCP。当发生某些事情时,您可以触发本地通知。

于 2015-10-03T16:28:55.367 回答
-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. 

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

希望这可以帮助。

于 2012-12-17T08:52:11.273 回答