ios - 呼叫目录分机 CallKit 无法识别超过 9 位的号码
问题描述
我正在使用 CallKit 并开发一个带有呼叫目录扩展的应用程序。我已经按照本教程进行操作,我目前正在测试识别用户在其联系人中没有的号码并显示我的应用程序中的 ID 的能力,但是虽然可以完美地处理 1 到 9 位数的数字,例如123456,当我设置 10 位或更多位的数字时,iOs 无法识别该数字。经过一天半的谷歌搜索,我没有找到任何相关信息。如果有人可以帮助我,我将不胜感激。提前致谢。
设置识别电话号码的方法:
private func addAllIdentificationPhoneNumbers(to context: CXCallDirectoryExtensionContext) {
// Retrieve phone numbers to identify and their identification labels from data store. For optimal performance and memory usage when there are many phone numbers,
// consider only loading a subset of numbers at a given time and using autorelease pool(s) to release objects allocated during each batch of numbers which are loaded.
//
// Numbers must be provided in numerically ascending order.
let allPhoneNumbers: [CXCallDirectoryPhoneNumber] = [ 123456789, 1_888_555_5555 ]
let labels = [ "ID test", "Local business" ]
for (phoneNumber, label) in zip(allPhoneNumbers, labels) {
context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
}
}
使用此代码,当我模拟号码为 123456789 的呼叫时,iOS 显示标签“ID 测试”,这是正确的,但如果我添加任何数字,例如末尾的 0:1234567890,iOS 不会显示任何内容模拟通话。我不知道我是否遗漏了什么。
解决方案
好吧,经过一堆测试,我可以让它工作。关键是电话必须包含完整的国家代码和区号。因此,例如 00_52_55_4567_8932 877 或 +52_55_4567_8932 都可以使用。但是 55_4567_8932 和 4567_8932 不起作用。我希望这可以在未来对其他人有所帮助。谢谢你们!
推荐阅读
- swagger - 如何使用请求标头配置 Swagger APIKey?
- python - 在 discord.py 中创建一个“成员”对象
- bash - apt-get 在使用循环结构时表现不同
- excel - 在 Excel VBA 中查找下标选项卡并将其替换为下标
- python - Gunicorn: Failed At step EXEC spawning No such file or directory
- rx-java - Better method to replace AsyncTask being deprecated to get data from server
- amazon-web-services - 如何使用 Boto3 检查 ELB 是否与任何自动缩放组相关联
- python - 从 NavigableString 中删除字符并附加到 python 中的列表
- spring-security - 执行不佳 org.springframework.security.authentication.ProviderManager.authenticate(Authentication)
- sql - 将查询从 MSSQL 转换为 PostgreSQL