问题
I am writing a VOIP application on iOS 5 and I am trying to understand how the actual communication can stay alive while in the background.
I understand there is a maximum amount of wakes the socket can get per amount of time. My problem is that my socket connection receive too many wakes messages, because of that the app is terminated with crash message:
exceeded 15 wakes in 300 sec
What I really don't understand is how is the socket supposed to be able to constantly send and receive data through it (for VOIP needs) if there is a limit for the amount of data it can receive per amount of time?
Let's say the socket is receiving voice data for a voice conversation that is happening while in the background. Is it not that voice data supposed to go through the socket connection? If so, how can it work if there is a limit for the activity the socket can have per amount of time?
回答1:
VOIP app behavior at background (iOS 4.0+):
VOIP apps should be flagged at info.plist, under "Required background modes", as "voip" & "audio".
Once you've opened an Audio Session (For active call), your app may run fully at the background and it is no longer suspended, until this Audio Session is closed.
Anyway, the other alternative, is to use Push notifications as triggers for incoming calls.
Also, this will save you the trouble of maintaining a socket 24/7, save some battery,
and will work even if the user has closed the app (which is not the case with the first alternative).
回答2:
What version of IOS, device that you are using?
This is a known "feature"/issue introduced by Apple in IOS5 to reduce battery usage of Voip apps...
来源:https://stackoverflow.com/questions/8746599/setkeepalivetimeout-ios-behavior-exceeded-15-wakes-in-300-sec