You can't use the public CoreTelephony call events handler with the private CoreTelephony functions like CTCallDisconnect. You can see a working example of the required private event handler code here: http://tech.ruimaninfo.com/?p=83 - they key bits:
// Register our event handler
id ct = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver(ct, NULL, callback, NULL, NULL, CFNotificationSuspensionBehaviorHold);
// Our callback
static void callback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
NSString *notifyname=(NSString *)name;
if ([notifyname isEqualToString:@"kCTCallIdentificationChangeNotification"])
{
NSDictionary *info = (NSDictionary *)userInfo;
CTCall *call = (CTCall *)[info objectForKey:@"kCTCall"];
NSString *caller = CTCallCopyAddress(NULL, call);
NSLog(@"Incoming call: %@",caller);
CTCallDisconnect(call);
}
}
I've confirmed this working on iOS5.1
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…