title: How to detect call incoming programmatically
body: <p>I need my app to send a notification when there is a call (incoming call, connected, call ended)
      I registered my viewController with notification.</p>
  
  <pre><code> [[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];
  </code></pre>
  
  <p>I also made a method to check call state</p>
  
  <pre><code>-(IBAction)checkForCall:(id)sender{
      NSLog(@"call state %@ id %@",call.callState,call.callID);
      CTCallCenter *callCenter = [[CTCallCenter alloc] init];
      callCenter.callEventHandler = ^(CTCall* call){
          if (call.callState == CTCallStateDisconnected)
          {
              NSLog(@"Call has been disconnected");
  
          }
          else if (call.callState == CTCallStateConnected)
          {
              NSLog(@"Call has just been connected");
  
          }
          else if(call.callState == CTCallStateIncoming)
          {
              NSLog(@"Call is incoming");
  
          }
          else
          {
              NSLog(@"None of the conditions");
          }
      };
  }
  </code></pre>
  
  <p>But none of this works. Please help me.</p>
  
  <p>Where is the mistake? Is there any code which tells how to use core telephony?</p>