使用coretelephony捕获传入的Callevent? [英] Capture incoming Callevent using coretelephony?

查看:67
本文介绍了使用coretelephony捕获传入的Callevent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to create an application for jailbroken iphone (ios 4.0 or greater). I want my application to remain running and whenever my phone starts ringing (for an incoming call), my application should be able to capture that "call incoming" event and based on that i could perform some function e.g. lower speaker volume.

任何人都可以引导我朝正确的方向前进,例如如何捕获此类事件,或者该事件是否在私有coretelephony框架中可用?

Can anyone guide me to the right direction, as to how can i capture such event, or if it is available in private coretelephony framework ?

推荐答案

您确定要监视呼叫而不使用

Are you sure you want to monitor calls and not use

- (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模板?

which is even in default XCode4 template?

如果您仍要进行呼叫监控-可以在iOS 4+上的Core Telephony的公共部分使用它

If you still want call monitoring - it's available in public part of Core Telephony on iOS 4+

#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");
        }
};

这篇关于使用coretelephony捕获传入的Callevent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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