We have to develop an iOS app that detect incoming and outgoing call states. We are able to get incoming call state but not getting the status for outgoing calls. For making a call we have to minimise our app, so that our app is now in background and henceforth we are not getting the background state. Following is the code to get the call states:
-(void)handleCall
{
self.callCenter.callEventHandler = ^(CTCall *call){
if ([call.callState isEqualToString: CTCallStateConnected])
{
NSLog(@"call connected");
}
else if ([call.callState isEqualToString: CTCallStateDialing])
{
NSLog(@"dialing...");
}
else if ([call.callState isEqualToString: CTCallStateDisconnected])
{
NSLog(@"Current CallID : %@",call.callID);
[[NSNotificationCenter defaultCenter] postNotificationName:@"callDisconnected" object:nil userInfo:nil];
}
else if ([call.callState isEqualToString: CTCallStateIncoming])
{
NSLog(@"call incoming");
}
};
}
Help me please to detect outgoing calls.