iosswiftreact-nativecallkit

it is possible to get incoming call number from in iOS and display caller name


Currently I am using the call Directory Extension with this simple code to show the caller name on the screen and it's working:

class CallDirectoryHandler: CXCallDirectoryProvider, CXCallDirectoryExtensionContextDelegate {
    func requestFailed(for extensionContext: CXCallDirectoryExtensionContext, withError error: Error) {
        
    }

    override func beginRequest(with context: CXCallDirectoryExtensionContext) {
        context.delegate = self
     
        context.addIdentificationEntry(withNextSequentialPhoneNumber: 92302XXXXXXX, label: "XYZ")

        context.completeRequest()
    }
}

Expected

What I want is on incoming call to get the phone number of who's calling and request the API to get data for this specific number only because it's not possible for me to save millions of numbers on the application.


Solution

  • As Paulw11 notes, what you're describing is not possible. Apps are intentionally extremely limited in what information they can get about user phone calls. However, a more common approach would be to provide a directory service, such as GAL, CardDAV, or LDAP. The user would then add that as a Contacts account (Settings > Mail, Contacts, Calendars > Add Account > Other), and the system will automatically perform lookups when needed. Accounts can be provided via a configuration profile so that the user doesn't have to hand-enter the information by hand.