首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >同一ios应用程序的两个背景任务

同一ios应用程序的两个背景任务
EN

Stack Overflow用户
提问于 2013-11-16 21:18:02
回答 1查看 88关注 0票数 0

我有一个ios应用程序,通过注册VOIP回调在后台运行。我是否可以手动启动和结束此正在运行的应用程序的2个后台任务。我正在IOS7上尝试这个。我认为苹果在ios7中设置了应用后台运行时间限制为3分钟。

EN

回答 1

Stack Overflow用户

发布于 2013-11-16 21:28:17

代码语言:javascript
复制
   If you want to let your VOIP application run in background , 
   except those base settings in plist file, you need a TCP socket who's property 
   is set to VOIP, than the iOS system will take care this socket for you,
   when your application enter background , every thing was 'sleep' except that 
   tcp socket. and if VOIP server send some data thought that TCP socket, 
   your application will be awake up for 10 secs. during this time, 
   you can post a local   notification.

   Only Tcp socket can be set as VOIP Socket. But from i know , 
   mostly VOIP application are based on UDP socket. if you do not want to separate 
   the control socket from the data socket. you should create another tcp 
   socket which is focus on 'awake' your application , 
   and from my personal experience , it's very hard to keep this 'awake' signal 
   and the real sip control signal synchronize, the application always miss 
   the sip invite request.

   So,the best way is separating the sip control single from the UDP data socket ,
   make it as a tcp socket , this is the best solution , 
   but never use tcp socket to transfer voice data.

   Another dirty way: keep the application awake all the time. 
   As i said , each TCP single the application received thought 
   that 'VOIP' tcp socket , will keep application awake for 10 seconds, 
   so at the end of this duration(after 9 secs) , 
   you can send a response to the server to ask for another signal , 
   when the next signal arrived, the application will be awake again,
   after 9 secs , send response again. keep doing this, 
   your application will awake forever.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20018918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档