关于READ_CONTACTS的权限问题使用问题
app有一个场景,需要判断当前的手机号是否属于通讯录号码,目前是基于ACL的ohos.permission.READ_CONTACTS权限来实现,下面是相关代码,此权限已经审核通过,现在上架的时候说不允许相关api,请问有什么办法可以替代吗?
/** scope=1:通过系统通讯录按号码查询,命中则推送(需 module 声明 READ_CONTACTS + Profile ACL + 用户授权) */
private static async matchSystemContacts(number: string): Promise<ContactMatchResult> {
const noMatch: ContactMatchResult = { matched: false, color: '', name: '' }
if (number.length === 0) {
return noMatch
}
const normalized = IncomingCallMonitor.normalizePhone(number)
if (normalized.length === 0) {
return noMatch
}
const scopeColor = IncomingCallMonitor.resolveScopeBleHex(1)
const ctx = IncomingCallMonitor.abilityContext
if (!ctx) {
return noMatch
}
const variants = IncomingCallMonitor.phoneLookupVariants(normalized)
const queryTasks = variants.map((v: string) => {
return contact.queryContactsByPhoneNumber(ctx, v).catch((_e: Object) => [])
})
const queryResults = await Promise.all(queryTasks)
for (let i = 0; i < queryResults.length; i++) {
const list = queryResults[i]
if (list && list.length > 0) {
const first = list[0]
let displayName = '通讯录联系人'
if (first && first.name && `${first.name.fullName ?? ''}`.trim().length > 0) {
displayName = `${first.name.fullName}`.trim()
}
const hit: ContactMatchResult = {
matched: true,
color: scopeColor,
name: displayName
}
return hit
}
}
return noMatch
} 1
1
8
浏览261 编辑于2026-07-28 07:17北京
全部评论
最多点赞
最新发布
最早发布
写回答
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要提问题
了解社区公约,与您携手共创和谐专业的开发者社区。









































苏公安网备 32011402010933号