iOS 10中的呼叫阻止功能

goo*_*4pc 5 iphone callblocking ios swift callkit

我正在尝试集成CallDirectory Extension以阻止某些来电.但应用程序甚至无法识别为阻止提供的数字.是否有人成功地做到了这一点?你可以看到我用过的格式..

   private func addIdentificationPhoneNumbers(to context: CXCallDirectoryExtensionContext) throws {

            let phoneNumbers: [CXCallDirectoryPhoneNumber] = [ 18775555555, 18885555555,+91949520]
            let labels = [ "Telemarketer", "Local business","myPhone"]

            for (phoneNumber, label) in zip(phoneNumbers, labels) {
                context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
            }
        }
Run Code Online (Sandbox Code Playgroud)

而且,我将此称为开发.http://iphoneramble.blogspot.in/2016/07/ios-10-callkit-directory-extension.html

测试设备和iOS版本 - iphone 5s,iOS 10.1

goo*_*4pc 5

最后,我有解决呼叫阻塞的方法。我还没有办法检查呼叫阻止代码是否正常工作。这是我为使其正常工作所做的一些事情。

  • 检查您的应用程序是否在64位iOS设备(iphone 5s或更高版本的设备)上运行
  • 以数字升序将数字相加
  • 将国家/地区代码添加到每个号码
  • 下面给出了添加用于阻止的手机号码的示例代码

    let phoneNumber:CXCallDirectoryPhoneNumber = CXCallDirectoryPhoneNumber(“ + 9194 ******”)!context.addBlockingEntry(withNextSequentialPhoneNumber:phoneNumber)

  • 检查您的应用是否已授予黑屏许可(设置->电话->呼叫阻止和识别->检查您的应用是否被允许阻止通话)

  • 您还可以通过将以下代码放在viewController中来检查enabledStatus

CXCallDirectoryManager.sharedInstance.getEnabledStatusForExtension(withIdentifier:“ bundleIdentifierOfYourExtension”,completeHandler:{(status,error)->如果让error = error {print(error.localizedDescription)}}无效)

  • 另外,将以下代码添加到viewController

CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier:“ bundleIdentifierOfYourExtension”,complementHandler:{(错误)->如果让错误=错误{print(error.localizedDescription)}}无效)

您会发现这些url对开发很有帮助。 http://iphoneramble.blogspot.in/2016/07/ios-10-callkit-directory-extension.html

https://translate.google.com/translate?hl=zh_CN&sl=zh-CN&u=http://colin1994.github.io/2016/06/17/Call-Directory-Extension-Study/&prev=search

请让我知道您是否有改进的方法和更正。谢谢,祝您编程愉快。


小智 1

电话号码数组必须是 int64 的排序列表。从最小到最大。否则,该列表将被拒绝,并出现“条目乱序”错误。