开发者

iphone: how to detect last caller number programmatically?

Is there any way to detect last caller number & call duration on iPhone, I开发者_如何学Go am able to get all notification (Core Telephony) but don't know how to get caller number.


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

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


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/


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜