Determine the number of incoming calls in iPhone

How do I know who is calling me? Identify the number or even the contact in my list that I have.

I can determine whether or not there is a call with this code.

void (^ctCallStateMuda)(NSNotification *) = ^(NSNotification * notification) {
    NSString *callInfo = [[notification userInfo] objectForKey:@"callState"];
    if ([callInfo isEqualToString:CTCallStateIncoming]) {
        NSLog(@">>>>>> chegando");
    } else if ([callInfo isEqualToString:CTCallStateConnected])  {
        NSLog(@">>> atendendo <<<");        
    }  else if ([callInfo isEqualToString:CTCallStateDisconnected])  {
        NSLog(@"desconectado >>>>>>");        
    } else if ([callInfo isEqualToString:CTCallStateConnected])  {
        NSLog(@"discando");        
    } else {
        NSLog(@"nada");        
    }
};

CTCallCenter *callCenter;
callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler = ^(CTCall* aCallIncomming) {
    NSDictionary *dict = [NSDictionary dictionaryWithObject:aCallIncomming.callState
                                                     forKey:@"callState"];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"CTCallStateDidChange"
                                                        object:self
                                                      userInfo:dict];
};

[[NSNotificationCenter defaultCenter] addObserverForName:@"CTCallStateDidChange" 
                                                  object:nil 
                                                   queue:nil 
                                              usingBlock:ctCallStateMuda];
0
source share
1 answer

You do not have access to this information in the public SDK (another jailbroken iPhone is another question). Apple prevents apps from accessing any call history information. The code that you posted above, so that your application can detect when the user receives a phone call and adapts his interface accordingly, but what is it.

+2
source

All Articles