i have a big problem. I am working on an app about accessibility. The app should work through the iPhone microphone to take over sounds from the environment (indoor) and compare them in real time with sounds in the app database (recorded from users previously). If sounds match, the user will be warned by the app through a notification. So... firstly, the app should listen sounds working in background, but after some minutes, iOS closes the app in background automatically. IS THERE SOME SOLUTIONS FOR THIS PROBLEM? TO ALLOW THE APP BE OPENED AND WORKING? Secondly, do you know in which way is possible compare sounds recorded with sounds listened by microphone in real time? Really really thank you.
2 Answers
Regarding the problem that your app is automatically closed, it seems that something was not configured properly in your project.
When the UIBackgroundModes key contains the audio value, the system’s media frameworks automatically prevent the corresponding app from being suspended when it moves to the background.
Make sure that you have enabled the "Audio, AirPlay and Picture in Picture" background mode in your project.

- 1,740
- 2
- 11
- 25
Fore the first question: Because your app will be recording the audio while in background, you can:
- set
UIBackgroundModes
key in your app’s Info.plist file toaudio
. It should keep your app alive when you pressHome
button. See the Declaring Your App’s Supported Background Tasks section - At some point, iOS can kill your app due to some conditions, but eventually it would restart your app later.
And be careful with this, you might have to deal with Apple Review team to prove that your app is not doing something harm to user privacy. Otherwise, they wouldn't let it go live.
For the second question: I think you can use some AI/Machine Learning service out there to do so. It's much more accurate and faster than building it your own.

- 293
- 1
- 3
- 14