2014-10-29 55 views
0

我有一個VOIP應用程序,但是,當有來電時也不會從待機模式喚醒文檔說以下內容:ios 8中的voip應用程序有新要求嗎?

There are several requirements for implementing a VoIP app: 

1. Enable the Voice over IP background mode for your app. (Because VoIP 
    apps involve audio content, it is recommended that you also enable 
    the Audio and AirPlay background mode.) You enable background modes 
    in the Capabilities tab of your Xcode project. 
// I did this using the "capabilities" tab in the project's settings. 
// I have "audio and airplay", "voice over ip", 
// "background fetch" and "remote notifications" checked. 

2. Configure one of the app’s sockets for VoIP usage. 
// I have 2 sockets, one for sending stuff to the server that closes after sending. 
// One socket that stays alive all the time, which is used to 
// receive stuff from the server. 
// The one that stays alive is configured as voip*. 

3. Before moving to the background, call the 
    setKeepAliveTimeout:handler: method to install a handler to be 
    executed periodically. Your app can use this handler to maintain its 
    service connection. 
// I did this and in the handler I send a login message to the server, 
// On the server side it's detected that the account is already logged in so 
// it refreshes the connection instead. 

4. Configure your audio session to handle transitions to and from active use. 
// I did not do this yet, I might in the future. 

5. To ensure a better user experience on iPhone, use the Core Telephony 
    framework to adjust your behavior in relation to cell-based phone 
    calls; see Core Telephony Framework Reference. 
// I did not do this and probably never will (company's decision, not mine). 

6. To ensure good performance for your VoIP app, use the System 
    Configuration framework to detect network changes and allow your app 
    to sleep as much as possible. 
// I don't do this yet, but will implement it once all the basics run fine. 

當有電話打進來,我創建一個本地通知,讓用戶知道該通話。當應用程序最小化時,這可以正常工作,但是當設備處於待機狀態(睡眠)時,不會有任何通知。當我將設備從待機狀態喚醒時,通知會在幾秒鐘後彈出(因此它尚未出現,它在喚醒設備後纔會出現)。

我在過去創建了更多的voip應用程序,我不記得曾經遇到過這個問題。我現在正在運行ios 8,或許我還需要做更多的工作才能使它在待機狀態下工作?現在是否有更多的voip要求?還是我錯過了一些愚蠢的東西?

注意:我知道推送通知。他們是一個選擇(事實上,我已經測試過,他們讓它工作),但我寧願不依賴於apns。

+0

您的VoIP控制套接字必須是TCP,而不是UDP。如果您將UDP套接字標記爲啓用VoIP,那麼這就是爲什麼當應用程序暫停時您沒有收到它的數據。請參閱http://stackoverflow.com/a/7393083/624920 – 2015-01-08 02:19:28

回答

0

請注意,如果用戶手動關閉應用程序(雙擊主頁按鈕,向上滑動),應用程序將無法在後臺運行,直到用戶手動打開它爲止。

但是,如果用戶強制退出,系統不會自動啓動您的應用程序。在這種情況下,用戶必須重新啓動您的應用程序或在系統嘗試再次自動啓動您的應用程序之前重新啓動設備。

檢查它here

+0

我在談論待機,而應用程序未關閉。顯然,一個應用程序不能執行代碼,而不會運行... – Kevin 2014-10-29 08:50:22

+0

好的,只是爲了確保在測試中你不關閉應用程序(向上滑動) – CarlesCF 2014-10-29 10:58:25

1

我剛花了整整兩天的時間解決了類似的問題。一部iPhone 6+正常工作,但兩部iPhone 6都沒有。長話短說,SIP數據包沒有被可靠傳輸。我ping了提供給我的VOIP服務器,發現我使用的延遲時間爲30毫秒,但延遲時間爲15毫秒,因此我試着切換服務器。那就是訣竅。

+0

嗨Haroldbasset,你能解釋更多關於延遲嗎?我在這裏遇到同樣的問題,我正在尋找解決方案。謝謝! – Phuong 2014-12-26 10:17:03

相關問題