gpt4 book ai didi

iphone - Monotouch 电话/通话状态?

转载 作者:行者123 更新时间:2023-11-29 13:46:09 28 4
gpt4 key购买 nike

在 Monotouch 中是否有任何方法可以读取电话或调用者服务的当前状态?

我正在尝试寻找某种方式来读取通话是否处于事件状态或通话是否处于等待状态等。

用谷歌搜索没有找到任何结果。

希望运行一些代码片段,例如:

if(CallIsActive) {

}
else {

}

我的解决方案:

public static class CallHandler
{
private static CTCallCenter ctc;
private static NSSet calls;

public static void StartListening() {
Console.WriteLine ("Callhandler is listening");
ctc = new CTCallCenter ();
calls = ctc.CurrentCalls;
ctc.CallEventHandler = new CTCallEventHandler (delegate(CTCall inCTcall) {
calls = ctc.CurrentCalls;

});
}

public static uint CallCount {
get {
return (calls != null) ? calls.Count : 0;
}
}

public static string GetCallState(int CallID) {
CTCall[] callArr = calls.ToArray<CTCall>();
CTCall call = callArr[CallID];
return call.CallState;

}
}

运行 CallHandler.CallCount 以获取当前调用计数和 GetCallState(0) 以获取第一个调用等。

最佳答案

我认为您正在寻找 CoreTelephony 框架。有一个苹果sample覆盖它。

using block-based event handlers to receive call events and carrier changes.

您需要将代码从 ObjectiveC 转换为 C#(查找 callStateToUser)。

关于iphone - Monotouch 电话/通话状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7330203/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com