Varietas Software Silent Switch Library (VSSilentSwitch)
The Problem -
Before iOS 5, developers would use the audio route to detect the position of the silent switch. This generally worked fairly well, but was never intended by Apple for this purpose. In fact, according to Apple, there is "no method for determining the silent switch state" present in the iOS frameworks. In iOS 5, the audio route method of determining the silent switch state was "fixed" and using this method no longer works. Apple doesn't want developers to be aware of this setting. If you set the appropriate audio session parameters, everything should "just work". But that's not always the case. There are several instances where a developer may want to know the state of the silent switch (mute switch) that aren't related to overriding the user's audio preferences. For instance, what if an app relies on audio, but the user has the mute switch on? The developer gets all sorts of reviews and email complaints about the software not working, when really the user just needed to turn off the mute switch.
The Solution -
Enter the VSSilentSwitch library. Using the library, developers can determine the state of the silent switch successfully in all versions of iOS. The library is entirely compact, and only adds a few kilobytes to your end-product. Only two standard Apple frameworks are required and you can be setup and using the library in under 5 minutes. The library uses 100% public API calls and is already used in several apps that are live in the app store, including our own eNotify. Using this library will not get you rejected by Apple.
To use the library, simply add it to your project. Make sure you've included the CoreTelephony and AudioToolbox frameworks in your project as well. Finally, add "-all_load" and "-ObjC" to the "Other Linker Flags" in your project's build settings. That's all you need to do!
Demo Project -
Feel free to download the demo library and try it out. We've included a demo project as well as the library so you can see that it works. This demo is time-limited to 15 minutes. After the 15 minutes are up, the library will start returning completely random results.