Problem And Question
I am developing one application. In that I want to detect through coding that “is iphone on silent mode or not?”. I am developing it by using cocoa with objective-c.
If anyone knows it kindly reply.
Best Solution And Answer
The reason Pirripli’s code does not work is that the simulator does not support the test and the code does not check for errors. Corrected code would look like:
CFStringRef state = nil; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); OSStatus status = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); if (status == kAudioSessionNoError) { return (CFStringGetLength(state) == 0); // YES = silent } return NO;