1

ジェイルブレイクされたiPhone(ios 4.0以降)用のアプリケーションを作成したいです。アプリケーションを実行したままにしておきたいのですが、電話が鳴り始めるたびに (着信コールの場合)、アプリケーションはその「着信」イベントをキャプチャできる必要があり、それに基づいてスピーカーの音量を下げるなどの機能を実行できます。

そのようなイベントをどのようにキャプチャできるか、またはプライベートコアテレフォニーフレームワークで利用できるかどうかについて、誰かが私を正しい方向に導くことができますか?

4

1 に答える 1

1

通話を監視し、使用しないでよろしいですか

- (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");
        }
};
于 2011-12-03T08:50:28.343 に答える