Detecting phone call interruption in iOS App

26 / Jun / 2015 by vishal.gupta 1 comments

One of the default behaviors of iOS is that it stops all the services & functions of the app while you are on a phone call.

While writing an audio-video iOS App, we must handle phone call’s interruption properly to resume the app. It is possible to detect a phone call and it’s states with the help of Core Telephony framework. Following steps will guide you to handle phone calls in your iPhones properly.

Steps to follow :

Add CoreTelephony Framework.

Import the following classes of CoreTelephony into your class wherever you need to handle or detect phone call’s interruption.

#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCall.h>

Make an object of CTCallCenter into your handler class.

@property (nonatomic, strong) CTCallCenter *objCallCenter;

Add a notification observer for call state changed inside your handler class viewDidLoad method.

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(CallStateDidChange:) name:@"CTCallStateDidChange" object:nil];

Write a call event handler for the  call center in viewDidLoad

self.objCallCenter = [[CTCallCenter alloc] init];
self.objCallCenter.callEventHandler = ^(CTCall* call) {
        // anounce that we've had a state change in our call center
        NSDictionary *dict = [NSDictionary dictionaryWithObject:call.callState forKey:@"callState"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"CTCallStateDidChange" object:nil userInfo:dict];

Write call state changed selector

- (void)CallStateDidChange:(NSNotification *)notification
    NSLog(@"Notification : %@", notification);
    NSString *callInfo = [[notification userInfo] objectForKey:@"callState"];
    if([callInfo isEqualToString: CTCallStateDialing])
        NSLog(@"Call is dailing");
    if([callInfo isEqualToString: CTCallStateIncoming])
        NSLog(@"Call is Coming");
    if([callInfo isEqualToString: CTCallStateConnected])
        NSLog(@"Call Connected");
    if([callInfo isEqualToString: CTCallStateDisconnected])
        //The call state Ended.
        NSLog(@"Call Ended");


Perform the tasks according to the phone call’s state.

Hope It Helps :)


comments (1 “Detecting phone call interruption in iOS App”)

Leave a comment - Simon Cancel reply