ios 检测ios中的呼叫事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18310332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Detecting the call events in ios
提问by Android Killer
I am new to ios. I was wondering if there is any way to detect the call events like incoming call, outgoing call even if my app is not in foreground. And if yes it is possible then can i read the details about that call like duration, whether it is missed, dialed or recieved. Thanks in advance.
我是ios的新手。我想知道是否有任何方法可以检测呼叫事件,例如来电、拨出电话,即使我的应用程序不在前台。如果是的话,那么我可以阅读有关该呼叫的详细信息,例如持续时间,无论是未接、已拨还是已接。提前致谢。
回答by rckoenes
Yes you can detect a Call. but only if your app is running in the foreground. For this you can use the Core Telephony Framework.
是的,您可以检测到呼叫。但前提是您的应用程序在前台运行。为此,您可以使用核心电话框架。
If your app will fall in any of the background running categories (VOIP, AUDIO, Location tracking or accessory ) you might be able to use the
CTCallCenter
in the background. But be aware that Apple will reject you app if you miss use the background running mode for something it was not meant for.
如果您的应用属于任何后台运行类别(VOIP、AUDIO、位置跟踪或附件),您或许可以
CTCallCenter
在后台使用 。但请注意,如果您错过将后台运行模式用于不适合的应用程序,Apple 将拒绝您的应用程序。
The CTCallCenter
will allow you to detect any calls that are started or already in progress.
这CTCallCenter
将允许您检测任何已开始或已在进行中的呼叫。
However you will not be able to detect any detail about the call, the CTCall
identifying the call will only tell you this state. The callID
of CTCall
will just give you an unique identifier for the call but not the number being called.
但是,您将无法检测到有关呼叫的任何详细信息,CTCall
识别呼叫只会告诉您此状态。该callID
的CTCall
只是给你呼叫的唯一标识符,但没有被调用的数量。