2012-10-31 41 views
5

我正在開發基於SIP和VoIP的iOS應用程序,並且要求即使在後臺也應該連續運行應用程序。我正在使用pjsip lib。iOS:在後臺接收媒體

我知道,在運行的bacground iPhone應用程序,我們需要在此的Info.plist

  • 集UIBackgroundModes鍵與創建的我傳遞給setKeepAliveTimeout一個處理VOIP值

  • :處理器:對於 保活連接

但我只是想,如果我的應用程序在後臺運行,可以我通過(RTP/RTCP)接收UDP數據包,同時我始終打開UDP端口。

我已經通過帖子了:

但是,我還沒有得到那個才能不斷得到UDP數據包甚至明確的想法應用程序在後臺或前臺。

因此,如果有任何數據來到iOS客戶端應用程序,應用程序應該能夠通知用戶。

請給出建議。

+2

嗨,請通過http://stackoverflow.com/questions/6601536/ios-voip-socket-will-not-run-in-background?rq=1這篇文章也可能對你有所幫助。 – User97693321

+0

你的意思是。你需要一種方法讓應用程序在後臺運行,以便在有電話時表明你? –

+0

btw ...你使用哪個版本的pjsip?你也使用zrtp? –

回答

-1

我想你可以在應用程序在後臺運行時設置本地通知,並通過通知指示用戶有來電。當用戶進入應用程序時,您可以顯示來電。

在下面的鏈接,查看 Background Execution and Multitasking and also Scheduling the Delivery of Local Notifications

IE,因爲你已經設置你的Info.plist的UIBackgroundModes鍵,您的應用程序將支持長時間運行的任務。因此,在applicationDidEnterBackground方法中添加一個方法,在有呼叫時創建一個UILocalNotification。 UILocalNotifications通知用戶警報消息和您選擇的語氣。因此,一旦用戶收到通知並且用戶進入該應用程序,該應用程序將前臺前往,您可以在其中添加該方法以接收該呼叫。

在LocalNotification的警報主體中,您可以將來電者的信息發送給用戶。

編輯:Check out the answer of Paul Richter in this link,他說

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. 

雖然不能完全與您所使用的圖書館,他給了過程的一個體面的交代。

希望這會有所幫助。

0

爲了在後臺運行VoIP應用程序並在服務器上註冊,應在iOS上使用TCP。發生什麼事情時,您可以啓動本地通知。