简体   繁体   English

在iOS中通过Twilio使用后台进程

[英]Using background processes in iOS with Twilio

I am developing a VoIP app using Twilio for iOS. 我正在使用iOS的Twilio开发VoIP应用。 The app should be able to receive incoming connections. 该应用程序应该能够接收传入的连接。 For that, I have checked the VoIP and Sound capabilities so that the app keeps running and listening for ports. 为此,我检查了VoIP和声音功能,以便该应用程序继续运行并监听端口。

To achieve this, I have initialized a TCDevice in my appDelegate and set the appDelegate to be the TCDeviceDelegate so that the system keep listening for new connections. 为此,我在appDelegate中初始化了TCDevice并将appDelegate设置为TCDeviceDelegate以便系统继续侦听新的连接。 But the app will eventually go into background, or even be terminated at some point. 但是该应用最终将进入后台,甚至在某个时候终止。 So what should I do at this point? 那么我现在该怎么办?

Is this the correct way for keeping the app listening even when in background? 这是即使在后台仍保持应用程序监听的正确方法吗? I have been reading that I need to use a setKeepAliveTimeout in my didEnterBackground method, but Apple says when using iOS8+ , we should be registering for Remote Notifications instead. 我一直在读,我需要使用setKeepAliveTimeout在我didEnterBackground的方法,但苹果公司称,使用iOS8上的+时,我们应该对注册远程通知来代替。

Also, I am reading the Apple documentations, and they say that sockets should be tagged properly for the system to keep these sockets alive. 另外,我正在阅读Apple文档,他们说插座应该正确标记,以使系统保持这些插座的活动性。 Does Twilio's library take care of these details? Twilio的图书馆会处理这些细节吗?

I am very confused about the whole process. 我对整个过程感到非常困惑。 Does Twilio take care of everything? Twilio会照顾一切吗? if so, how? 如果是这样,怎么办?

The Twilio SDK calls the setKeepAliveTimeout for you so you don't need to call that or worry about the sockets. Twilio SDK为您调用setKeepAliveTimeout,因此您无需调用它或担心套接字。 All you need to do is add the two background settings to your info.plist for Playback of Audio and VOIP. 您需要做的就是将两个背景设置添加到info.plist中,以播放音频和VOIP。

The Twilio online documentation is not that great, however if you download the iOS SDK and untar it you will find a FAQ which is NOT online that explains more. Twilio在线文档不是很好,但是,如果您下载iOS SDK并解压缩,则会发现不是在线的FAQ,它会解释更多信息。 You will also find a BasicPhone Xcode project that is way more fleshed out than the Monkey project. 您还将找到一个比Monkey项目更加充实的BasicPhone Xcode项目。

Also I found that unless you cough up some money then none of the calls will actually go through. 我还发现,除非您掏出钱,否则所有电话都不会接听。

If you encounter any problems then the Twilio email support is great for the first 48 hours of each issue and then they tend to go silent. 如果您遇到任何问题,那么Twilio电子邮件支持非常适合每个问题的前48小时,然后它们通常会保持沉默。 YMMV. 因人而异。

All of this is information I could have done with 2 months ago, hope it helps. 所有这些都是我两个月前可以完成的信息,希望能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM