iOS如何检查当前是否正在通话 [英] iOS How to check if currently on phone call

查看:777
本文介绍了iOS如何检查当前是否正在通话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我环顾四周,我能找到的就是检查CTCallCenter的callState。但是,这可以通过监听事件来实现 - 这取决于应用程序是否处于活动状态/暂停/恢复,事件可以在不同时间引发。

I have look around and all I can find is checking the callState of CTCallCenter. However, this works by listening to an event - which depending on whether the application is active/suspended/resumed the event can be raised at different time.

我需要的是我想决定自己何时连接来电,而不是听取事件并告知事件。

What I need is rather than listening to event and got told when call is connected, I want to decide myself when to ask if the call is connected.

使用案例:连接电话时 - 用户知道并将始终单击应用程序图标,这将打开该应用程序。这时我只想运行快速功能来检查当前是否正在通话。

Use case: When phone call is connected - user knows and will always click on the app icon, which will open the app. At this time I just want to run a quick function to check if currently on call or not.

这是否可能?

推荐答案

CTCallCenter 对象有一个 currentCalls 属性,这是当前调用的 NSSet 。如果有电话,那么 currentCalls 属性应为!= nil。

The CTCallCenter object has a currentCalls property which is an NSSet of the current calls. If there is a call then the currentCalls property should be != nil.

如果你想知道是否有调用实际上是连接的,那么你将不得不迭代当前的调用并检查 callState 以确定它是否是 CTCallStateConnected 或不。

If you want to know if any of the calls is actually connected, then you'll have to iterate through the current calls and check the callState to determine if it is CTCallStateConnected or not.

这篇关于iOS如何检查当前是否正在通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆