Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any other iOS system sounds available other than 'tock'?

I have implemented an alternative keyboard on my first iPhone app. I would like to play a sound when a button is pressed. The default click sound when the standard keyboard is pressed would be fine, but I don't know how to get that sound.

In this answer I found how to play a 'tock' sound:

Playing system sound without importing your own

I got this to work easily enough but it is a very loud sound. I've searched Stack Overflow and the Xcode help for available iOS system sounds other than 'tock' and I can't find them.

Are there other built-in sounds, maybe even the default keyboard sound, that I can use?

like image 596
Dale Dietrich Avatar asked Sep 03 '12 23:09

Dale Dietrich


People also ask

What are iPhone system sounds?

System Sound Services provides a C interface for playing short sounds and for invoking vibration on iOS devices that support vibration. You can use System Sound Services to play short (30 seconds or shorter) sounds.

Can you add more Background Sounds to iPhone?

Go to Settings > Accessibility > Audio/Visual > Background Sounds, then turn on Background Sounds. Set any of the following: Sound: Choose a sound; the audio file downloads to your iPhone. Volume: Drag the slider.

How do I add sounds to my iPhone?

Navigate to Settings -> Sounds on your iPhone or iPod touch (or, on your iPad, Settings -> General -> Sounds), and tap on the alert sound you wish to change. Now scroll to your newly-created sound—it'll be listed under the Ringtones section, but don't worry; you can use it for any of your alerts.


1 Answers

Prior to, and since posting this question almost 2 weeks ago I have searched high and low for a method to make the keyboard click sound work in my app. I have attempted to implement and understand Apple's documentation on custom input views. I butchered my app in many ways attempting to make it work and created several test projects. I tried to interpret how to do this from various other sources on the web. All to no avail. I have finished my app all but for this last function.

I finally hit on a simple answer towards the end of this IPhone Dev SDK form question/post. The ultimate answer is easy and can be done in a few seconds with these easy steps.

  1. Link the 'AudioToolbox.framework' to your project (Click on your project's Target, select 'Build Phases' and under the 'Link Binary with Libraries' item click the + button and add the framework.

  2. Add the following to the header file of the class where you want to implement the click:

     #import <AudioToolbox/AudioToolbox.h>
    
  3. Add the following line of code in the implementation file of your class wherever you want the keyboard click sound to appear:

     AudioServicesPlaySystemSound(0x450);
    

THAT'S IT! AND IT WORKED!!! HALLELUJAH!

According to Paul in the other forum this has the following downside:

"keyboard keys won't be affected by the iOS user preference for keyboard sound on/off."

But when I turn the volume up or down on my iPhone or if I mute the iPhone, the keyboard click sounds do go up and down or are muted as would be expected. Given that I found it impossible to implement keyboard clicks "UIInputViewAudioFeedback" as documented, I'm happy to have anything work.

P.S. If anyone has a link to an actual project that I can download, build and run on my iPhone to see EXACTLY how to properly implement: "UIInputViewAudioFeedback" I'd be happy to give it a look. But so far I've found none, nor any step-by-step newbie style instructions on how to make it work.

[Sept 30, 2012 UPDATE:] I'm happy to say that my app was accepted into the app store using this method. Here it is: https://itunes.apple.com/app/fine-tip-tip-calculator/id563429225

...Dale

like image 188
Dale Dietrich Avatar answered Sep 28 '22 21:09

Dale Dietrich