Is there any way to detect last caller number & call duration on iPhone, I am able to get all notification (Core Telephony) but don\'t know how to get caller number.
You can use this
if ([name isEqualToString:@"kCTCallIdentificationChangeNotification"])
{
// CTCallCenter *center = [[CTCallCenter alloc] init];
// center.callEventHandler = ^(CTCall *call) {
// NSLog(@”call:%@”, [call description]);
// };
//NSDictionary *info = (NSDictionary *)userInfo;
CTCall *call = (CTCall *)[info objectForKey:@"kCTCall"];
NSString *caller = CTCallCopyAddress(NULL, call);
NSLog(@"caller:%@",caller);
//CTCallDisconnect(call);
/* or one of the following functions: CTCallAnswer
CTCallAnswerEndingActive
CTCallAnswerEndingAllOthers
CTCallAnswerEndingHeld
*/
//if ([caller isEqualToString:@"+1555665753"])
if ([caller isEqualToString:@"+918740061911"])
{
NSLog(@"disconnecting call");
//disconnect this call
CTCallDisconnect(call);
}
}