【问题标题】:What is the right way to update CXCallDirectoryExtensionContext label?更新 CXCallDirectoryExtensionContext 标签的正确方法是什么?
【发布时间】:2018-01-09 13:32:07
【问题描述】:
我开始使用 CallKit 来识别号码。在许多错误之后它正在工作,但我找不到在 if 更改后更新标签的方法。现在我知道如果我删除标识并再次添加它两次调用 CXCallDirectoryManager.sharedInstance.reloadExtension (第一次我删除,第二次我添加更新的标签相同)号)。
一个电话就可以做到吗?
//to remove I'm using:
context.removeIdentificationEntry(withPhoneNumber: 1234567890)
//to add:
context.addIdentificationEntry(withNextSequentialPhoneNumber: 1234567890, label: "new label")
【问题讨论】:
标签:
ios
swift
ios-extensions
callkit
【解决方案1】:
目前,这是唯一的方法。
根据Apple's 文档,添加新条目只有两种方法。
// Adds a blocking entry with the specified phone number.
func addIdentificationEntry(withNextSequentialPhoneNumber: CXCallDirectoryPhoneNumber, label: String)
// Adds a blocking entry with the specified phone number.
func addBlockingEntry(withNextSequentialPhoneNumber: CXCallDirectoryPhoneNumber)
它们还提供了 4 种删除或清除条目的方法。
func removeAllBlockingEntries()
func removeAllIdentificationEntries()
func removeBlockingEntry(withPhoneNumber: CXCallDirectoryPhoneNumber)
func removeIdentificationEntry(withPhoneNumber: CXCallDirectoryPhoneNumber)
但是...没有更新现有条目。