Silent Mode Detection in iOS 7

Is there any way to detect silent mode in iOS 7?

The following code does not work for iOS 5 or later

-(BOOL)silenced { #if TARGET_IPHONE_SIMULATOR // return NO in simulator. Code causes crashes for some reason. return NO; #endif CFStringRef state; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); if(CFStringGetLength(state) > 0) return NO; else return YES; } 
+5
ios iphone ios7
source share
1 answer

Check this topic - Does Detecting Ring / Silent / Mute iPhone Switch Using AVAudioPlayer Not Work?

And this API is SoundSwitch

How it works:

  • Play audio file for 0.5 seconds, every second (after completion ..)
  • Check how long it took to play the sound.
  • Is the callback called fast? nothing was played (silent switch on)

Enjoy it!

+13
source share

All Articles