Handle interruptions from alerts during voice recording
I am working on a voice recording app wherein there could be interruption by phone calls, text messages, and/or system alerts. As for phone calls, I realize the recording has to be stopped and have worked this out successfully. My challenge seems to be with other alerts such as low-battery status, alarms, text messages, etc. For now, I have managed to pause and save recording as soon as an alert interrupt pops up, but am looking at more efficient options.
In most real-world scenarios on ad-hoc distribution mode, I notice that my users do not even monitor the iPhone or iPod screen when recording their voices. Also, in case we 开发者_如何转开发test this app on the iPod Touch, then the sounds for the alerts are pretty feeble and they miss out on the alerts and continue recording only to realize after a few minutes or maybe at the end of the session that the recording was interrupted.
Here are my questions:
- Is it possible to continue recording voice in the background in the event of any system alerts or text message alerts popping up?
- If not, would it be possible to make the app play a particular sound in the background that would continue to play until the user realizes something is wrong, looks into the screen, and if they dismiss the system alert then it would make the app come to the foreground and so stop the audio alert as the app has now gained focus, then can choose to continue recording from where they left off.
Any help would be greatly appreciated. Any other idea to handle this situation is most welcome.
You could try to implement application delegate methods
-(void)applicationWillResignActive:(UIApplication *)application{
[recorder playSound];
[recorder pause];
}
-(void)applicationDidBecomeActive:(UIApplication *)application{
[recorder record];
}
Put those methods in the appDelegate class.
If you want to implement your own alert do it in the applicationWIllResignActive, but I am not sure if you should do it, cause all the alerts like SMS, push notifications or battery warning trigger vibrations and sounds.
精彩评论