Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
720 views
in Technique[技术] by (71.8m points)

ios - How to use call directory extension to identify a incoming call in my application?

I am working on callKit framework, I found that by the use of call directory extension, we can Identify the incoming phone number. My question how to implement a call directory extension in iOS app to identify incoming call detail. I am working in Objective C.

Let a number "+919876xxxxx" add in call directory extension using this method:

- (BOOL)addIdentificationPhoneNumbersToContext:(CXCallDirectoryExtensionContext *)context {
    // Numbers must be provided in numerically ascending order.
    CXCallDirectoryPhoneNumber phoneNumbers[] = {+919876xxxxx};

    NSArray<NSString *> *labels = @[ @"Telemarketer"];
    NSUInteger count = (sizeof(phoneNumbers) / sizeof(CXCallDirectoryPhoneNumber));

    for (NSUInteger i = 0; i < count; i += 1) {
        CXCallDirectoryPhoneNumber phoneNumber = phoneNumbers[i];
        NSString *label = labels[i];
        [context addIdentificationEntryWithNextSequentialPhoneNumber:phoneNumber label:label];
    }
    return YES;
}

And I on the call blocking and identification feature in the phone settings. When I call from this number it show the [App name] Caller ID: Telemarketer.

My question is how can I know this number in my application so that I show this number in table.

Thanks in Advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If this question is not how to write a call directory extension, but how to get the number of an incoming call, which I think is what the question is, then its not possible.

The call directory extension is not involved when there is an incoming call. All it does is register numbers that get stored in an internal SQL database that is private to the phone app. The call directory extension does NOT get run when there is an incoming call and therefore it and your app are not able to identify the number of an incoming call, this is the same as it has always been, it has not changed in iOS 10.

There is new functionality for call detection for Voip apps that was added in iOS 10, but if you are not a voip app you still cannot obtain the number of an incoming (or outgoing) call.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...