iOS - 呼叫发生时的通知? [英] iOS - Notification of when a call is taking place?
问题描述
是否可以在 iOS 手机上进行 GSM/CDMA 呼叫时收到通知或检测到?
Is it possible to be notified or detect when a GSM/CDMA call is taking place on an iOS handset?
我有一个在后台使用音频的应用程序,我希望能够检测到呼叫何时发生,以便我的应用程序可以做出相应的反应,以免以任何方式干扰手机通话.
I have an application that uses audio in the background and I want to be able to detect when a call is taking place so that my app can react accordingly so as not to intrude on the cellular call in anyway.
从本质上讲,我希望能够检测到通话何时发生,这样如果用户在通话时进入我的应用程序,我就可以禁用某些功能.
Essentially I want to be able to detect when a call is taking place so that if the user enters my application while on a call I can disable some functionality.
所以我想知道如何检测设备上正在进行蜂窝电话通话?
So I was wondering how I can detect that a cellular call is taking place on a device?
推荐答案
从 iOS 4 开始,您可以使用 CTCallCenter 类用于注册事件处理程序,以便您的应用在呼叫时收到通知开始或结束.它给你的 CTCall 有一个 callState
属性,它可以是 CTCallStateDialing
、CTCallStateIncoming
、CTCallStateConnected
,或者——当结束——CTCallStateDisconnected
.
As of iOS 4, you can use the CTCallCenter class in the Core Telephony framework to register an event handler so your app gets notified when a call starts or ends. The CTCall it gives you has a callState
property, which can be CTCallStateDialing
, CTCallStateIncoming
, CTCallStateConnected
, or—when it ends—CTCallStateDisconnected
.
这篇关于iOS - 呼叫发生时的通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!