1
votes

Does anyone know of an effective way to record audio whilst the device is locked on iOS?

Currently I am using two AVAudioRecorders, one to listen out for noises (audioListener) and one to actually record those noises (audioRecorder). The audioListener is always recording and getting the meter levels of the noises as it needs to be recording in order to get those levels. If those noises go above a threshold then the audioRecorder starts recording for five seconds and in the audioRecorderDidFinishRecording method will add each audio file to an array for reference later. I have also already set the "Application does not run in background" key in the info.plist to NO and allowed the audio background mode.

I still need to do a few more tests to see if it records correctly when the device is locked but was wondering anyone knew of any other ways of accomplishing this?

1

1 Answers

0
votes

You need to set the audio category to AVAudioSessionCategoryPlayAndRecord as well as the background audio mode as you have done.

Check out the AudioSession Programming Guide