gpt4 book ai didi

iphone - 使用 coretelephony 捕获传入的 Callevent?

转载 作者:行者123 更新时间:2023-11-29 13:47:49 24 4
gpt4 key购买 nike

我想为越狱的 iPhone(iOS 4.0 或更高版本)创建一个应用程序。我希望我的应用程序保持运行状态,每当我的电话开始响铃(来电)时,我的应用程序应该能够捕获该“来电”事件,并基于此我可以执行某些功能,例如降低扬声器音量。

任何人都可以指导我正确的方向,关于我如何捕获此类事件,或者它是否在私有(private)核心电话框架中可用?

最佳答案

你确定要监听通话不使用

- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}

哪个甚至在默认的 XCode4 模板中?

如果您仍然想要通话监控 - 它在 iOS 4+ 上的 Core Telephony 的公共(public)部分可用

#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>

....

CTCallCenter *callCenter;//make it ivar if you are using ARC or handler will be auto-released
..
callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler=^(CTCall* call)
{
NSLog(@"Call id:%@", call.callID);

[self callStateChange:call.callState andId:call.callID];
if (call.callState==CTCallStateDialing)
{
NSLog(@"Call state:dialing");
}
if (call.callState==CTCallStateIncoming)
{
NSLog(@"Call state:incoming");
//here you lower your speaking volume if you want
}
if (call.callState==CTCallStateConnected)
{
NSLog(@"Call state:connected");
}
if (call.callState==CTCallStateDisconnected)
{
NSLog(@"Call state:disconnected");
}
};

关于iphone - 使用 coretelephony 捕获传入的 Callevent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6519902/

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