How to record audio from the microphone in iOS

Talk-Icon-512Recording audio is a complex process – for any computer. iOS makes it simple-ish with several classes courtesy of the AV Foundation Framework.

In this example we’ll record audio from the device microphone. This happens in four steps:

  • create an AVSession
  • setup a dictionary with audio recorder settings
  • create an AVAudioRecorder
  • prepare for and start recording

For the method below to work you need to import and link the AVFoundation Framework to your project. We also need a property to hold our AVRecorder object, otherwise it will no longer exist by the time the method reaches the end and nothing will work. Again.

Here’s a method that is called by a “Record Button”:

This content is for members only.

Additional delegate methods are available to check for a “higher power” interruption, such as a phone call.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.