我的手机:iOS 5.1.1 使用 Absynth2 越狱
我正在尝试做的事情: 检测来电或正在拨打电话......
好的,这是我放在AppDelegate
下面的代码didEnterBackground
,也试过了didResignActive
- 我没有得到任何错误,但我也没有得到任何结果..
callCenter = [[CTCallCenter alloc] init];
[callCenter setCallEventHandler:^(CTCall *call) {
NSDictionary *dict = [NSDictionary dictionaryWithObject:call.callState forKey:@"callState"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"CTCallStateDidChange" object:nil userInfo:dict];
NSLog(@"state changed on call: %@", call);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callReceived:) name:CTCallStateIncoming object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callDial:) name:CTCallStateDialing object:nil];
任何帮助表示赞赏。谢谢!