title: Detect silent mode in iOS 7
body: <p>is there any way to detect silent mode in iOS 7?</p>
  
  <p>the following code does not work for iOS 5 or later version</p>
  
  <pre><code>-(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, &amp;propertySize, &amp;state);
      if(CFStringGetLength(state) &gt; 0)
              return NO;
      else
              return YES;
  
     }
  </code></pre>