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