tags:

views:

128

answers:

1

Hi! I'm working on custom keyboard and need to play tap sound for keys if it enabled in the Settings. Tap sound not a problem but how to check is keyboard click sound enabled ? Thanks.

+7  A: 

There's no documented way to check this, but it's possible. I don't know if this really counts as "private API", so be prepared for rejection if you use this method.

The keyboard click sound settings is stored in the shared com.apple.preferences.sounds preference. So you could try

return CFPreferencesGetAppBooleanValue(
        CFSTR("keyboard"),
        CFSTR("/var/mobile/Library/Preferences/com.apple.preferences.sounds"),
        NULL);

(BTW: the actual call to play the "click" sound in UIKit is [UIHardware _playSystemSound:1104];)

KennyTM
The CFPreferencesGetAppBooleanValue call works perfectly, but UIHardware isn't recognised (or anywhere in the docs) for me. Instead, I added the AudioToolkit framework and called `AudioServicesPlaySystemSound( 1104 )` for the same effect.
Kris Jenkins
@Kris: That's because UIHardware is a private class.
KennyTM