iphone: how to detect last caller number programmatically?

后端 未结 4 1741
攒了一身酷
攒了一身酷 2021-01-14 21:10

Is there any way to detect last caller number & call duration on iPhone, I am able to get all notification (Core Telephony) but don\'t know how to get caller number.

相关标签:
4条回答
  • 2021-01-14 21:50

    You can use this

    if ([name isEqualToString:@"kCTCallIdentificationChangeNotification"])
        {
            // CTCallCenter *center = [[CTCallCenter alloc] init];
            // center.callEventHandler = ^(CTCall *call) {
            // NSLog(@”call:%@”, [call description]);
            // };
    
            //NSDictionary *info = (NSDictionary *)userInfo;
            CTCall *call = (CTCall *)[info objectForKey:@"kCTCall"];
            NSString *caller = CTCallCopyAddress(NULL, call);
            NSLog(@"caller:%@",caller);
            //CTCallDisconnect(call);
            /* or one of the following functions: CTCallAnswer
             CTCallAnswerEndingActive
             CTCallAnswerEndingAllOthers
             CTCallAnswerEndingHeld
             */
    
            //if ([caller isEqualToString:@"+1555665753"])
            if ([caller isEqualToString:@"+918740061911"])
            {
                NSLog(@"disconnecting call");
                //disconnect this call
                CTCallDisconnect(call);
    
            }
    
        }
    
    0 讨论(0)
  • 2021-01-14 21:52

    According to api you cant do it... but here something which might help you ... though I haven't tried it myself... http://iosstuff.wordpress.com/2011/08/19/accessing-iphone-call-history/

    0 讨论(0)
  • 2021-01-14 21:54

    You can't, the API will not allow you to do this.

    I think apple will never allow this due to privacy concerns.

    0 讨论(0)
  • 2021-01-14 21:56

    Apple officially don't allow.You cann't access the database of the other application then your one.

    0 讨论(0)
提交回复
热议问题