I want to get the state of phone call either it in dialed, connected or disconnected...
I tried my self but i cant get the state.
NSString *phoneNumb
Here is how I have done it. As suggested above, I have used it in AppDelegate, but the entire block is also in appDelegate and I don't monitor the state, but check if the call was nil or not.
In AppDelegate.h file
#import
#import
#import
@interface AppDelegate : UIResponder
@property (nonatomic, strong) CTCallCenter *center;
@property (nonatomic, assign) BOOL callWasMade;
@end
In AppDelegate.m file
- (void)applicationDidEnterBackground:(UIApplication *)application
{
self.center = [[CTCallCenter alloc]init];
typeof(self) __weak weakSelf = self;
self.center.callEventHandler = ^(CTCall *call) {
if(call!=nil) {
NSLog(@"Call details is not nil, so user must have pressed call button somewhere in the alert view");
weakSelf.callWasMade = YES;
}
};
}
Using the callWasMade
boolean property, you can carry on performing your tasks. This property can be referenced in any ViewController by getting a handle to the AppDelegate. I hope you find this snippet useful.