objective c - iOS - Playing Tock sound for custom keyboard -


i trying play tock sound custom keyboard.

what have tried:

[[uidevice currentdevice] playinputclick]; 

and

nsstring *path = [[nsbundle bundlewithidentifier:@"com.apple.uikit"] pathforresource:@"tock" oftype:@"aiff"]; systemsoundid soundid; audioservicescreatesystemsoundid((cfurlref)[nsurl fileurlwithpath:path], &soundid); audioservicesplaysystemsound(soundid); audioservicesdisposesystemsoundid(soundid); 

and

audioservicesplaysystemsound(0x450); 

and

nsstring *soundfilepath = [[nsbundle mainbundle] pathforresource:@"test" oftype: @"mp3"]; nsurl *fileurl = [[nsurl alloc] initfileurlwithpath:soundfilepath ]; myaudioplayer = [[avaudioplayer alloc] initwithcontentsofurl:fileurl error:nil]; myaudioplayer.numberofloops = 1; [myaudioplayer play]; 

this gave me error:

audiosessionclient: couldn't connect com.apple.audio.audiosession couldn't connect com.apple.audio.audioqueueserver; audioqueue not usable 

and looked link

when tried these codes in viewcontrollers (not custom keyboard) worked. when tested on custom keyboard idled @ least 10 seconds , couldn't hear anything.

i made sure iphone not on silent mode, speaker not broken, keyboard clicks enabled. tested these codes on iphone , ipad , turned out same

xcode version 6.3.1 ios version 8.3

what doing wrong? in advance.

i found solution problem.

in info.plist.

requestsopenaccess = yes 

and code on keyboardviewcontroller.m

dispatch_async(dispatch_get_main_queue(), ^{         audioservicesplaysystemsound(1104);     }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -