Jordan H
Jordan H

Reputation: 55735

Play standard iOS keyboard click sound in Custom Keyboard Extension

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.

Upvotes: 18

Views: 4034

Answers (1)

user3180187
user3180187

Reputation: 117

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

Upvotes: 10

Related Questions