iOS4中检测通话状态
我想知道是否有可能检测用户是否正在从当前处于后台的应用程序进行通话。
或者,如果通话是从我的应用程序发起的,则在通话结束时收到通知。
或者,更重要的是 - 是否有可能检测哪个应用程序位于前台?
我不相信这是可能的,但我必须尝试...;-)
任何信息将不胜感激。
谢谢。
I would like to know if there is a possibility to detect if the user is in call from an application that is currently in background.
Or, receive a notification when the call is ended if the call was initiated from my app.
Or, even more than that - is there a possibility to detect which app is in foreground?
I don't believe that this is possible but I had to try... ;-)
Any info will be appreciated.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
CTCallCenter
中,有一个callEventHandler
方法,您可以传递一个在呼叫事件发生时将被调用的块。在此块中,您将传递一个CTCall
对象,并可以获得callState
。因此,您可以在呼叫发起或结束时收到通知,并进行适当的处理。您无法得知哪个应用程序发起了调用,但如果您在调用时设置了 ivar,则可以知道是您的应用程序发出了调用。例如:
编辑:重新阅读您的问题,您希望在暂停时发生这些事件,对吗?我认为这是不可能的。
来自 文档:
In
CTCallCenter
, there is a method,callEventHandler
that you can pass a block that will get called when call events happen. In this block, you'll be passed aCTCall
object, and can get thecallState
. So, you can get a notification when a call is initiated or ended, and handle it appropriately. You can't get which application initiated the call, but if you set an ivar when you make the call, you can tell that it's your application that made the call.For example:
EDIT: Re-reading your question, you want these events while you are suspended, correct? I don't think that's possible.
From the docs:
如果您的应用程序在后台运行并且有 AVAudioSession 正在进行,您将在 AVAudioSessionDelegate 告诉您接到电话时您的 AVAudioSession 已被中断。 AFAIK 这就是您获得的所有信息。
If you're app is running in the background and has an AVAudioSession going, you will receive callbacks on the AVAudioSessionDelegate telling you that your AVAudioSession has been interrupted when a phone call is received. AFAIK that's all the info you get.