17

I was wondering if there's new API in iOS 8 that will allow you to play the standard keyboard click sound in a keyboard extension - and only play it if they have the keyboard clicks enabled and the device isn't on silent. I haven't seen such an API, and I haven't seen any questions about this.

I do know in previous iOS versions this was possible if you implemented a custom input or keyboard accessory view (via [[UIDevice currentDevice] playInputClick]; after you adopt the UIInputViewAudioFeedback protocol and return YES in enableInputClicksWhenVisible). This was possible only in those situations. A keyboard extension is neither of those.

Is it possible to play the input click with a custom iOS keyboard?

Note that this question is related, but they wanted a custom sound, and the solution will not respect the user's preference for playing keyboard clicks - will always play them even when that option has been disabled.

Community
  • 1
  • 1
Jordan H
  • 52,571
  • 37
  • 201
  • 351

1 Answers1

10

just use

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),     
^{
AudioServicesPlaySystemSound(1104);
});    

the tirck is ,when the full access is enabled ,the sound will play ,if not ,because it's call is in the background thread will no block the main thread

user3180187
  • 117
  • 1
  • 3
  • 2
    Just curious how to get the various sound IDs? – Ethan Long Sep 30 '14 at 16:10
  • it's save,and i have a keyboard posted on store – user3180187 Oct 20 '14 at 02:30
  • This does play the sound, but it always plays it even if the user disabled Keyboard Clicks in Settings. Surely they don't appreciate that. – Jordan H Jan 08 '15 at 20:33
  • Heed Apple's warning with this approach: "This is not a supported API. Third parties aren't supposed to call first party system sounds." – Jordan H Jan 21 '15 at 00:58
  • Wasted too much time not to contribute on SO. Given the answer has the issues outlined by Joey, I guess the only way is to use this with a switch from the keyboard container app. I cannot find a better answer. – Hiwa Apr 18 '15 at 11:10
  • That is what SwiftKey app uses too. Time to ask a question or edit this question may be? – Hiwa Apr 18 '15 at 19:40