I need to write a background application in iOS which listens to incoming phone calls on the iPhone.
Is it possible? Can anyone suggest some good pointers ?
Thankyou
I need to write a background application in iOS which listens to incoming phone calls on the iPhone.
Is it possible? Can anyone suggest some good pointers ?
Thankyou
This would be very much against Apple's privacy policy and there's no chance an app like this would be approved.
There are call recording apps that sneak around this restriction, though, but they use third party services and no actual built-in iPhone API's.
You can do it in applicationWillEnterForeground using CTCallCenter's CTCallState properties. Don't forget to import the CoreTelephony framework. Here's an example:
#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[callCenter setCallEventHandler:^(CTCall *call) {
if ([[call callState] isEqual:CTCallStateIncoming] || [[call callState] isEqual:CTCallStateDialing]) {
if ([viewController isPlaying])
{
NSLog(@"Call was started.");
}
} else if ([[call callState] isEqual:CTCallStateDisconnected]) {
if (callWasStarted)
{
NSLog(@"Call was ended.");
}
}
}];
}