13

I know that if I start an audio recording session in foreground, with Audio, Airplay, and Picture in Picture activated in Capabilities -> Background Modes; I am able to continue to record even in background, but only if I start the recording session in foreground and then I go in background.

My problem is that I want to start the voice recording session from background, which might seem shaddy and not what Apple wants, but the use case is like this:

I have a Bluetooth LE device with buttons and an iOS app. Those two are paired (Bluetooth LE device and the iPhone which runs the iOS app) and the iOS app is listening for events on the Bluetooth LE device, events like a hit of a button.

Now, when the user hits a button on the Bluetooth LE device, the iOS app captures the event and I am able to run code even if the app is in background, but I am not able to start a voice recording.

My question is: is that even possible? To start a voice recording from background? Even if we have user interaction here, not on the iOS app but on the Bluetooth LE, so it's not like the voice recording starts in background and the user is not aware of it, he pressed the button on the Bluetooth LE device, he knows what he's doing.

Any help, documentation, tweet of an Apple engineer, anything would be much appreciated. Thanks.

UPDATE: MFI is not required. https://mfi.apple.com/MFiWeb/getFAQ.action#1-2.

If you look into the section:

"What types of accessories and technologies are NOT part of the MFi Program?"

You will see that:

"Accessories that use only Bluetooth Low Energy (BTLE) (note: BTLE-enabled HomeKit accessories and BTLE-enabled MFi Hearing Aids are part of the MFi Program)"

Is mentioned, which means MFI in this case is not required.

Mihai Erős
  • 1,129
  • 1
  • 11
  • 18
  • You can do this (I did it for a now defunct startup, hope your idea is better)! The essential ingredients are: background audio&bluetooth modes and recording using a software codec (non hardware). – Rhythmic Fistman Feb 06 '17 at 00:45
  • Do you know any app on the AppStore that currently does this? – Mihai Erős Feb 07 '17 at 06:18
  • No, but I'm sure there are some. Dictation software comes to mind? – Rhythmic Fistman Feb 07 '17 at 06:21
  • I am not sure you understand what am I looking for. About dictations software, well, why a dictation software would have to start a voice recording while in background? – Mihai Erős Feb 07 '17 at 07:43
  • To be ever ready to record your voice at the press of a BTLE button regardless of the phone's lock screen state for example? I'm guessing here. In any case I am not aware of any currently available app on the store that does this. That doesn't mean one doesn't exist. Feel free to use itunes' search feature. – Rhythmic Fistman Feb 07 '17 at 07:50
  • @RhythmicFistman The work you done at a startup involved starting recording when the app is woken up in the background due to a BLE accessory action or a significant location change? – George Feb 08 '17 at 10:15
  • in response to a BLE accessory event – Rhythmic Fistman Feb 10 '17 at 03:00
  • @MihaiErős, have you ever been able to make this work (start an audio recording from a BLE device, while the app is in background) ? Thanks is advance – Franck Jul 09 '19 at 13:32
  • @MihaiErős Did you find any way to start audio recording while application running in background ? Thanks in Advance. – Jay Bhalani Jan 04 '22 at 11:56

2 Answers2

6

From Apple Documentation

An app that plays or records audio continuously (even while the app is running in the background) can register to perform those tasks in the background. You enable audio support from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the audio value in your app’s Info.plist file.) Apps that play audio content in the background must play audible content and not silence.

Typical examples of background audio apps include:

Music player apps Audio recording apps Apps that support audio or video playback over AirPlay VoIP apps

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:

  • Apps that record audio content while in the background

EDIT:

Also regarding your "Bluetooth device":

Check out the documentation for ExternalAccessory .

Be aware that you need to apply and get approved for a special developer program in order to be able to create external accessories.

  • Thanks, this might be helpful, I thought that if my bluetooth device gets certified by Apple, or something like this, I might be able to do what I want. Any idea how can I apply for that special developer program? – Mihai Erős Feb 04 '17 at 16:55
  • @MihaiErős np, check here: https://developer.apple.com/programs/mfi/ , please mark as answered if it answers your question. GL –  Feb 04 '17 at 17:13
  • Thanks but MFI is not required since I use Bluetooth LE. So this doesn't help me.. – Mihai Erős Feb 07 '17 at 07:45
  • "So this doesn't help me" , **then please edit your post and rephrase what your question is**, so far your question reads: **My question is: is that even possible? To start a voice recording from background? And the answer is : Yes!** which is clearly written here and also citated from the documentation. And if you don't need the MFI program, then good for you, that makes things easier don't they? –  Feb 07 '17 at 14:22
  • Before you go ahead and give a piece of advice, you should know what MFI stands for, when it's required and when not. I specified that I am using Bluetooth LE, you jumped ahead and gave an answer without verifying it. See the FAQ on the Apple's MFI page. Thank you again, don't start a war, be nice. – Mihai Erős Feb 09 '17 at 11:32
  • Where do you see in the documentation that Apple says you can start a voice recording FROM background? Please point me to that paragraph. That would really be helpful. – Mihai Erős Feb 09 '17 at 11:32
  • "Don't start a war" . Please avoid your low-level comments on SO. I clearly said this answer answers your question which I bolded out for you above. If you have any other questions feel free to edit your question or create a new question. Thanks for clearing out what MFI stands for, now develop an app with an Bluetooth LE device that calls the iOS Bluetooth API and acts as a controller for recording audio, and get it approved by Apple without an MFI developer program. Please update this post when you do, I will personally buy your product and make sure all my friends buy it too. Good luck! –  Feb 09 '17 at 16:14
  • We actually did that, we have an app on the AppStore that works, but we do have issues with starting a voice recording while app is in background. Here is the link:https://mfi.apple.com/MFiWeb/getFAQ.action#1-2. If you look into the section "What types of accessories and technologies are **NOT** part of the MFi Program?", you will see that: **Accessories that use only Bluetooth Low Energy (BTLE) (note: BTLE-enabled HomeKit accessories and BTLE-enabled MFi Hearing Aids are part of the MFi Program)** is mentioned, which means MFI in this case is not required. – Mihai Erős Feb 10 '17 at 08:11
  • @MihaiErős I don't think you understood me correctly. **Running a custom control bluetooth device that triggers recording audio from the background.** I don't know how Apple will react to that. However, you should look into http://stackoverflow.com/questions/19932090/how-to-wake-up-ios-app-with-bluetooth-signal-ble and , https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html awaking the App with the bluetooth connection –  Feb 10 '17 at 11:34
  • @MihaiErős BTW You need to take into account that awaking the app automatically from the background and running a task by bluetooth notification event is not the same as recording audio in background. While you may have your app up and running , starting record, and pushing it to background, is not the same as iOS starting the app for you and executing the audio recording in background using system resources without the users "input" and merely from the bluetooth notification only. I have not tried out the limitations or went into further details on this however. GL. –  Feb 10 '17 at 11:46
  • That's exactly the problem, I can catch the BLE event when the app is in background, and I try to start a voice recording, but nothing happens. I can clearly see that this is some kind of limitation, but I am looking for a concrete reason or maybe a solution to the problem. Right now, I totally agree with you, that using system resources in background without the users input/user interaction and merely from the BLE notification/event/response seems to be a violation of Apple's privacy policy, at least. – Mihai Erős Feb 10 '17 at 13:34
  • @MihaiErős Yeah, that's why I strongly think that you would need an MFI for this, but I am not 100% sure , what you can do however, without an MFI, is to check out the ExternalAccessory framework in my answer, and see if that somehow allows a easier method to fire off anything, if it does, then I think you will need an MFI to use that framework, not sure since I havent tested it myself tho. However, I have not tested the frameworks and the differences between them compared to the Bluetooth framework etc. GL. –  Feb 10 '17 at 17:45
  • 1
    The documentation link now redirects to something else, do you know where to find the current version ? (I especially cannot find if "Apps that record audio content while in the background" is still a valid reason to get the audio background permission) – Alexis R Aug 27 '19 at 09:28
1

Helpful tips::

It turns out that Apple's SpeakHere sample code with some modifications will start recording audio in the background if you just add the audio multitasking flag to information. You might look https://github.com/benvium/SpeakHere for an updated version of SpeakHere since Apple hasn't updated it in awhile.

bob marti
  • 1,523
  • 3
  • 11
  • 27
  • 2
    Not to be "that guy" but that sample code seems to be over 6 years old? :P have you tested it? –  Feb 03 '17 at 08:56
  • 2
    I actually tried SpeakHere, with some modifications I was able to run that project on iOS 10. But I can't start a voice recording in background, if I start it in foreground and then I switch to background it works, but that's not helpful. – Mihai Erős Feb 04 '17 at 16:53