How can I get the caller's phone number from an incoming call on iphone

Hi, I want to create an application that does something when an incoming call arrives. But I think the phone should be hacked on the iphone in order to access the class that does this. I want to do this without hacking the phone.

+3
source share
2 answers

Impossible.

However, you can get information such as call status (connected / disconnected, etc.) using the CoreTelephony framework .

+2
source

If you want to do something when calls come or go, you should use this code:

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");
    }
};

, . , . , . , ur. , . .

0

All Articles