我想在键盘扩展中按键时发出咔嗒声,但前提是在iOS设置中启用了此偏好设置。这是之前被问到here,但答案(适用于Swift 3)
var keyExistsAndHasValidFormat: DarwinBoolean = true
let isKeyboardClickSoundEnabledByUser = CFPreferencesGetAppBooleanValue(
"keyboard" as CFString,
"/var/mobile/Library/Preferences/com.apple.preferences.sounds" as CFString,
&keyExistsAndHasValidFormat
);
适用于iOS 9但不适用于iOS 10 - keyExistsAndHasValidFormat
始终返回false。如果要测试它,请使用真实设备而不是模拟器。
Apple最近restricted the shortcuts for Settings,但我不确定这是否会影响阅读偏好。也许路径发生了变化?