首页 > 解决方案 > CallKit:从被阻止的电话号码中接听电话

问题描述

我正在关注本教程https://www.raywenderlich.com/1276414-callkit-tutorial-for-ios,发现我在阻止列表中指定的电话号码可以拨打(除了那些在联系人中被阻止的号码)。`class CallDirectoryHandler: CXCallDirectoryProvider {

override func beginRequest(with context: CXCallDirectoryExtensionContext) {
    context.delegate = self

    context.addBlockingEntry(withNextSequentialPhoneNumber: 2222)
    context.addIdentificationEntry(withNextSequentialPhoneNumber: 1111, label: "RW Tutorial Team")
           
    context.addIdentificationEntry(withNextSequentialPhoneNumber: 353_1800_200_321, label: "Friendly Caller")
    
    context.completeRequest()
}

和电话检索:

 let update = CXCallUpdate()
    update.remoteHandle = CXHandle(type: .phoneNumber, value: handle)
    update.hasVideo = hasVideo
    
    self.provider.reportNewIncomingCall(with: uuid, update: update) { error in
        if error == nil {
            let call = Call(uuid: uuid, handle: handle)
            self.callManager.add(call: call)
        }
        
        completion?(error)

因此,对于 1111,我得到“RW 教程团队”标签,对于 353_1800_200_321,结果相同,但对于 2222,我收到来电。请帮忙。

标签: iosswiftiphonecallkit

解决方案


推荐阅读