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

眉间皱痕 提交于 2019-11-27 09:22:47

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.

Firstly you need to enable your CallBlocker app in App Setting for that follow this -

Go to Settings->Phone->Call blocking & identification->Enable your App.

After that use addIdentificationEntry for adding entry

  private func addIdentificationPhoneNumbers(to context: CXCallDirectoryExtensionContext) throws {

        let phoneNumbers: [CXCallDirectoryPhoneNumber] = [ 18775555555, +919899999999 ]
        let labels = [ "Telemarketer", "Local business" ]

        for (phoneNumber, label) in zip(phoneNumbers, labels) {
            context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
        }
    }

Which is working fine in Xcode 8.x swift 3.x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!