After lots of googling i find the best & Simple solution to detect Audio Jack
first of all add following method in your code
- (BOOL)areHeadphonesPluggedIn {
NSArray *availableOutputs = [[AVAudioSession sharedInstance] currentRoute].outputs;
for (AVAudioSessionPortDescription *portDescription in availableOutputs) {
NSLog(@"%@",portDescription.portType);
if ([portDescription.portType isEqualToString:AVAudioSessionPortHeadphones]) {
return YES;
}
}
return NO;
}
then test it like
if ([self areHeadphonesPluggedIn] == TRUE) {
NSLog(@"Device Detetcted. Headphone PluggedIn");
}
else {
NSLog(@"Device Not Detetcted. Headphone PluggedOut");
}
Very Simple!