VSSilentSwitch for iOS

34
Buy Now ($20.00) Binary License


Author
5b8a4dd8b5110340d2fddba6d4dc72b2

Josh Pressnell
More from this Author...

About

Need to work out the state of the iPhone's silent switch in iOS 5?

This simple static library lets you do just that with a single call.

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. You need to add 6 Apple frameworks 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.

Setup

To use the library, simply add it to your project. Make sure you've included the CoreTelephony, AudioToolbox, MobileCoreServices, SystemConfiguration, libz.dylib, and CFNetwork 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!

License

You must acquire an individual license for for the Component for each unique application bundle ID you choose to use the Component in. For development purposes, you must utilize the TRIAL version of the Component. Before submission to the app store or release to an Enterprise customer, the final build of the application must be updated to link to the RELEASE version of the Component, which can be purchased here via CocoaControls.com. Return to CocoaControls.com to purchase additional licenses. The TRIAL version of the Component is freely redistributable for evaluation and development purposes.

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.

Download Demo Project Here

Apps using this Control

Use this control in your apps? Let us know! I Use This Control!

Found a bug, have a problem? Check out the Cocoa Controls FAQ before posting a comment.

blog comments powered by Disqus