Is it theoretically possible to record a phone call on iPhone?
I'm accepting answers which:
- may or may not require the phone to be jailbroken
- may or may not pass apple's guidelines due to use of private API's (I don't care; it is not for the App Store)
- may or may not use private SDKs
I don't want answers just bluntly saying "Apple does not allow that". I know there would be no official way of doing it, and certainly not for an App Store application, and I know there are call recording apps which place outgoing calls through their own servers.
Apple does not allow it and does not provide any API for it.
However, on a jailbroken device I'm sure it's possible. As a matter of fact, I think it's already done. I remember seeing an app when my phone was jailbroken that changed your voice and recorded the call - I remember it was a US company offering it only in the states. Unfortunately I don't remember the name...
Yes. Audio Recorder by a developer named Limneos does that (and quite well). You can find it on Cydia. It can record any type of call on iPhone 5 and up without using any servers etc'. The call will be placed on the device in an Audio file. It also supports iPhone 4S but for speaker only.
This tweak is known to be the first tweak ever that managed to record both streams of audio without using any 3rd party severs, VOIP or something similar.
The developer placed beeps on the other side of the call to alert the person you are recording but those were removed too by hackers across the net. To answer your question, Yes, it's very much possible, and not just theoretically.
Further reading
The only solution I can think of is to use the Core Telephony framework, and more specifically the callEventHandler property, to intercept when a call is coming in, and then to use an AVAudioRecorder to record the voice of the person with the phone (and maybe a little of the person on the other line's voice). This is obviously not perfect, and would only work if your application is in the foreground at the time of the call, but it may be the best you can get. See more about finding out if there is an incoming phone call here: Can we fire an event when ever there is Incoming and Outgoing call in iphone?.
EDIT:
.h:
ViewDidLoad:
AppDelegate.m:
This is the first time using many of these features, so not sure if this is exactly right, but I think you get the idea. Untested, as I do not have access to the right tools at the moment. Compiled using these sources:
Recording voice in background using AVAudioRecorder
http://prassan-warrior.blogspot.com/2012/11/recording-audio-on-iphone-with.html
Can we fire an event when ever there is Incoming and Outgoing call in iphone?
Here you go. Complete working example. Tweak should be loaded in
mediaserverd
daemon. It will record every phone call in/var/mobile/Media/DCIM/result.m4a
. Audio file has two channels. Left is microphone, right is speaker. On iPhone 4S call is recorded only when the speaker is turned on. On iPhone 5, 5C and 5S call is recorded either way. There might be small hiccups when switching to/from speaker but recording will continue.A few words about what's going on.
AudioUnitProcess
function is used for processing audio streams in order to apply some effects, mix, convert etc. We are hookingAudioUnitProcess
in order to access phone call's audio streams. While phone call is active these streams are being processed in various ways.We are listening for CoreTelephony notifications in order to get phone call status changes. When we receive audio samples we need to determine where they come from - microphone or speaker. This is done using
componentSubType
field inAudioComponentDescription
structure. Now, you might think, why don't we storeAudioUnit
objects so that we don't need to checkcomponentSubType
every time. I did that but it will break everything when you switch speaker on/off on iPhone 5 becauseAudioUnit
objects will change, they are recreated. So, now we open audio files (one for microphone and one for speaker) and write samples in them, simple as that. When phone call ends we will receive appropriate CoreTelephony notification and close the files. We have two separate files with audio from microphone and speaker that we need to merge. This is whatvoid Convert()
is for. It's pretty simple if you know the API. I don't think I need to explain it, comments are enough.About locks. There are many threads in
mediaserverd
. Audio processing and CoreTelephony notifications are on different threads so we need some kind synchronization. I chose spin locks because they are fast and because the chance of lock contention is small in our case. On iPhone 4S and even iPhone 5 all the work inAudioUnitProcess
should be done as fast as possible otherwise you will hear hiccups from device speaker which obviously not good.I guess some hardware could solve this. Connected to the minijack-port; having earbuds and a microphone passing through a small recorder. This recorder can be very simple. While not in conversation the recorder could feed the phone with data/the recording (through the jack-cable). And with a simple start button (just like the volum controls on the earbuds) could be sufficient for timing the recording.
Some setups