Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 328
Jordan H Avatar asked Jul 10 '14 04:07

Jordan H


1 Answers

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

like image 196
user3180187 Avatar answered Oct 05 '22 01:10

user3180187