I wonder, if there's a way to get reason of applicationWillResignActive being called?
I'm developing an audio app, and I want to continue recording sound when the screen is auto locked, but I want to stop recording when incoming call occurs. How can I do that?
You can simply use the AVAudioSessionDelegate protocol methods like: beginInterruption and/or endInterruptionWithFlags: to check if the recording is interrupted and than you can do whatever you need.
In this case this approach has an advantage over registering to telephony events, because it works all the time recording, and not only for the first 10 minutes.
You can refer to the Core Telephony Framework in your application. This framework gives you the possibility of listening to the events and state of the phone on your device.
Moreover, the CTCallCenter class gives you the possibility of registering to telephony events to appropriately handle them through your application. This way you will be able to call a specific callback when an incoming call arrives, a call is started, terminated and so on. See the full list of cellular call states.
Hope this helps.
Related
Is there a way to programatically check if the audio system is being exclusively used on the iPhone? If an app tries to use the audio system when a FaceTime or cellular phone call is active, it will get errors when trying to start up audio. I'd like to check if the audio system is being exclusively used before attempting to start up audio.
The app I'm working on is a VOIP type app. When there is an incoming call, I'd like to check if the audio system is usable before the call is allowed to be answered. I have tried CTCallCenter and it works for cell phone calls, but FaceTime calls don't show up in there.
Thanks,
Conway
Couldn't you initialize the audio input as soon as the incoming call is detected and start the queue once the user accepts the call?
Look at the interruption handling delegates in the audio session documentation.
https://developer.apple.com/Library/ios/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Introduction/Introduction.html
You can set a flag in your app to prevent answering of your voice call if you are between beginInterruption and endInterruption methods.
I have requirement
1) when application start the send to background by launching any other app like open url in safari.
2) when it will go into background then it will wait for incoming call.
I have done first one and after so much R&D i get that in background our app will alive for 10 minutes after that it will auto kill. So how do second ne point?
This is app not for jail-broken device. And according to apple rules what methods i can use?
Thanks in advance...
Take a look at Core Telephony Framework Reference.
And CTCall Class Reference / CTCallCenter Class Reference
I want to know how to generate local notification at the end of the incoming call in Iphone using core telephony frame work
You can't intercept every phone call, unless your app is an app that is allowed to run in th background. Like VOIP, navigation (or other GRPS tracker) or playing audio.
You can use the apple example to see if there is a call active and set the callEventHandler block.
Then check if there the is ended by checkin if the callState is equal to CTCallStateDisconnected.
I have a video recording app. Everything works fine. Except when a phone call is received while recording.
When a phone call is received, I try to end the recording, however, any of my calls to write to an AVAssetWriter are denied. audioWriterInput appendSampleBuffer returns no, appendPixelBuffer errors out. I try to call avAssetWriter finishWriting but that returns AVAssetWriterStatusFailed.
Nothing works, my video is corrupted because it seems that my usual methods to finish up a recording session are not being allowed once a call is received.
What could I listen for to properly end a recording session when a phone call is received? The only thing I can currently do is listen for applicationWillResignActive and stop everything, but that prevents recording while a user receives a text message, etc. which would make my app work differently than the native Camera app.
Take a look at the Core Telephony framework, and specifically the CTCallCenter class. You can register an callEventHandler which is a block that accepts a CTCall object. This object describes the call state. Try to end recording when the call object indicates it's an incoming call.
I'm developing for a jailbroken device, and I want to create an app that detects a phone call, and presents an alert on top of the call screen. How can I achieve this? What hidden frameworks should I use?
Within CoreTelephony is the CTCallCenter class which includes the callEventHandler property, which is a block that runs upon changes in the call state. As described in the documentation, you could use this to become notified of these states:
CTCallStateDialing;
CTCallStateIncoming;
CTCallStateConnected;
CTCallStateDisconnected;
Docs say you must be in active app state. If you are suspended, then you only get one block state change notification upon waking up. If you are jailbroken and in background state, hopefully you would get your block executed, so you could become aware of this.