title: How can we check if iPhone keyboard click sound is turned on/off in settings in iOS 10?
body: <p>I want to have click sounds when pressing keys in my keyboard extensions, but only if that preference is enable in iOS Settings. This was previously asked <a href="https://stackoverflow.com/questions/2704074/how-to-check-iphone-keyboard-klick-sound-turned-on-off-in-settings">here</a>, but the answer (adapted for Swift 3)</p>
  
  <pre><code>var keyExistsAndHasValidFormat: DarwinBoolean = true
  let isKeyboardClickSoundEnabledByUser = CFPreferencesGetAppBooleanValue(
      "keyboard" as CFString,
      "/var/mobile/Library/Preferences/com.apple.preferences.sounds" as CFString,
      &amp;keyExistsAndHasValidFormat
  );
  </code></pre>
  
  <p>works in iOS 9 but not in iOS 10 – <code>keyExistsAndHasValidFormat</code> always returns false. If you want to test it, use a real device instead of the simulator.</p>
  
  <p>Apple has recently <a href="http://www.iphonehacks.com/2016/10/ios-10-no-longer-lets-you-open-settings-shortcuts-from-widgets.html" rel="nofollow noreferrer">restricted the shortcuts for Settings</a>, but I'm not sure if that affects reading the preferences. Maybe the path has changed?</p>