- (void)addInterruptionNotification {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:@"AVAudioSessionInterruptionNotification" object:nil];
}

- (void)handleInterruption:(NSNotification *) notification{
    if (notification.name != AVAudioSessionInterruptionNotification || notification.userInfo == nil) {
        return;
    }
    
    NSDictionary *info = notification.userInfo;
    
    if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
        
        if ([[info valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeBegan]]) {
            NSLog(@"InterruptionTypeBegan");
            //Do something when interruption begins

        } else {
            NSLog(@"InterruptionTypeEnded");
            
            //Do something when interruption ends
        }
    }
}
