我已经在我的应用程序中实现了呼叫目录扩展来识别被叫 ID。但在接到电话时无法查看我的应用程序名称或来电者详细信息。由于 Apple 的安全原因,无法调试呼叫目录扩展。在下面包含了我的代码。
override func beginRequest (with context: CXCallDirectoryExtensionContext) {
// --- 1
guard let phoneNumbersToBlock = retrievePhoneNumbersToBlock () else {
NSLog ( "Unable to retrieve phone numbers to block" )
let error = NSError (domain: "CallDirectoryHandler" , code: 1 , userInfo: nil )
context.cancelRequest (withError: error)
return
}
// --- 2
for phoneNumber in phoneNumbersToBlock {
let phoneNumberr : CXCallDirectoryPhoneNumber = CXCallDirectoryPhoneNumber(phoneNumber)!
context.addBlockingEntry (withNextSequentialPhoneNumber: phoneNumberr)
}
// --- 3
guard let (phoneNumbersToIdentify, phoneNumberIdentificationLabels) = retrievePhoneNumbersToIdentifyAndLabels () else {
NSLog ( "Unable to retrieve phone numbers to identify and their labels" )
let error = NSError (domain: "CallDirectoryHandler" , code: 2 , userInfo: nil )
context.cancelRequest (withError: error)
return
}
// --- 4
for (phoneNumber, label) in zip (phoneNumbersToIdentify, phoneNumberIdentificationLabels) {
let phoneNumberrr : CXCallDirectoryPhoneNumber = CXCallDirectoryPhoneNumber(phoneNumber)!
context.addIdentificationEntry (withNextSequentialPhoneNumber: phoneNumberrr, label: label)
}
// --- 5
context.completeRequest ()
}
private func retrievePhoneNumbersToBlock () -> [ String ]? {
// retrieve list of phone numbers to block
return [ "+ 919488775260" ]
}
private func retrievePhoneNumbersToIdentifyAndLabels () -> (phoneNumbers: [ String ], labels: [ String ])? {
// retrieve list of phone numbers to identify, and their labels
return ([ "+ 919385338505" ], [ "test" ])
}
如果启用任何配置,我可能会错过。请帮我。