通話を監視し、使用しないでよろしいですか
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
これはデフォルトのXCode4テンプレートにもありますか?
それでも通話の監視が必要な場合は、iOS4以降のCoreTelephonyのパブリック部分で利用できます
#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>
....
CTCallCenter *callCenter;//make it ivar if you are using ARC or handler will be auto-released
..
callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler=^(CTCall* call)
{
NSLog(@"Call id:%@", call.callID);
[self callStateChange:call.callState andId:call.callID];
if (call.callState==CTCallStateDialing)
{
NSLog(@"Call state:dialing");
}
if (call.callState==CTCallStateIncoming)
{
NSLog(@"Call state:incoming");
//here you lower your speaking volume if you want
}
if (call.callState==CTCallStateConnected)
{
NSLog(@"Call state:connected");
}
if (call.callState==CTCallStateDisconnected)
{
NSLog(@"Call state:disconnected");
}
};