Merged
查询符合条件的通话记录 #135463
xuwenlongAdd on Mar 24
查询符合条件的通话记录 #135463
Merged
xuwenlongAdd on Mar 24
Merged fromDeleted :masterintoopenharmony/docsmaster
Total: 1 files changed+117-0
@@ -4417,6 +4417,123 @@ contact.addContacts(context, [contactInfo1, contactInfo2]).then((data) => {
4417});4417});
4418```4418```
4419 4419 
4420+## contact.hasMatchedCallLog<sup>24+</sup>
4421+ 
4422+hasMatchedCallLog(context: Context, phoneNumber: string, minDuration: number, withinTime: number): Promise&lt;boolean&gt;
4423+ 
4424+检查是否有符合条件的通话记录,仅针对运营商通话。使用Promise异步回调。
4425+ 
4426+**原子化服务API**:从API version 24开始,该接口支持在原子化服务中使用。
4427+ 
4428+**需要权限**:ohos.permission.CHECK_CALL_LOG
4429+ 
4430+**系统能力**:SystemCapability.Applications.ContactsData
4431+ 
4432+**参数:**
4433+ 
4434+| 参数名 | 类型 | 必填 | 说明 |
4435+| ------- | ------------------- | ---- | ------------------------------------------------------------ |
4436+| context | Context | 是 | 应用上下文Context,Stage模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-application-context.md)。 |
4437+| phoneNumber | string | 是 | 联系人的电话号码。 |
4438+| minDuration | number | 是 | 最短通话时长,单位为秒,取值范围大于0。 |
4439+| withinTime | number | 是 | 表示从当前时间开始计算,通话的起始时间和结束时间应在此时间范围内,单位为秒。最多可设置6小时,超过6小时的默认以6小时查询。 |
4440+ 
4441+**返回值:**
4442+ 
4443+| 类型 | 说明 |
4444+| --------------------- | --------------------------------- |
4445+| Promise&lt;boolean&gt; | Promise对象,返回是否有符合条件的通话记录,true代表有符合条件的,false代表没有。 |
4446+ 
4447+**错误码:**
4448+ 
4449+以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Contacts错误码](../apis-contacts-kit/errorcode-contacts.md)。
4450+ 
4451+| 错误码ID | 错误信息 |
4452+| -------- | ------------------ |
4453+| 201 | Permission denied. |
4454+| 16700001 | General error. |
4455+| 16700002 | Invalid parameter value. |
4456+ 
4457+**示例:**
4458+ 
4459+>**说明:**
4460+>
4461+>在本文档的示例中,通过this.context来获取UIAbilityContext,其中this代表继承自UIAbility的UIAbility实例。如需要在页面中使用UIAbilityContext提供的能力,请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
4462+ 
4463+```js
4464+import { contact } from '@kit.ContactsKit';
4465+import { common } from '@kit.AbilityKit';
4466+ 
4467+// 请在组件内获取context
4468+const context = this.getUIContext().getHostContext() as common.UIAbilityContext;
4469+ 
4470+const phoneNumber = '13812345678';
4471+const minDuration = 60;
4472+const withinTime = 2 * 60 *60;
4473+ 
4474+// 调用接口查询
4475+contact.hasMatchedCallLog(context, phoneNumber, minDuration, withinTime).then((hasMatch:boolean) => {
4476+ console.info(`Has matched call log: ${hasMatch}`);
4477+});
4478+```
4479+ 
4480+## contact.hasMatchedCallLog<sup>24+</sup>
4481+ 
4482+hasMatchedCallLog(context: Context, phoneNumber: string, minDuration: number): Promise&lt;boolean&gt;
4483+ 
4484+检查是否有符合条件的通话记录,默认查询6小时以内的通话记录,仅针对运营商通话。使用Promise异步回调。
张译心
张译心张译心Mar 24

不支持查询6小时以上的记录吗

likedislike
4485+ 
4486+**原子化服务API**:从API version 24开始,该接口支持在原子化服务中使用。
4487+ 
4488+**需要权限**:ohos.permission.CHECK_CALL_LOG
4489+ 
4490+**系统能力**:SystemCapability.Applications.ContactsData
4491+ 
4492+**参数:**
4493+ 
4494+| 参数名 | 类型 | 必填 | 说明 |
4495+| ------- | ------------------- | ---- | ------------------------------------------------------------ |
4496+| context | Context | 是 | 应用上下文Context,Stage模型的应用Context定义见[Context](../apis-ability-kit/js-apis-inner-application-context.md)。 |
4497+| phoneNumber | string | 是 | 联系人的电话号码。 |
4498+| minDuration | number | 是 | 最短通话时长,单位为秒,取值范围大于0。 |
4499+ 
4500+**返回值:**
4501+ 
4502+| 类型 | 说明 |
4503+| --------------------- | --------------------------------- |
4504+| Promise&lt;boolean&gt; | Promise对象,返回是否有符合条件的通话记录,true代表有符合条件的,false代表没有。 |
4505+ 
4506+**错误码:**
4507+ 
4508+以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Contacts错误码](../apis-contacts-kit/errorcode-contacts.md)。
4509+ 
4510+| 错误码ID | 错误信息 |
4511+| -------- | ------------------ |
4512+| 201 | Permission denied. |
4513+| 16700001 | General error. |
4514+| 16700002 | Invalid parameter value. |
4515+ 
4516+**示例:**
4517+ 
4518+>**说明:**
4519+>
4520+>在本文档的示例中,通过this.context来获取UIAbilityContext,其中this代表继承自UIAbility的UIAbility实例。如需要在页面中使用UIAbilityContext提供的能力,请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
4521+ 
4522+```js
4523+import { contact } from '@kit.ContactsKit';
4524+import { common } from '@kit.AbilityKit';
4525+ 
4526+// 请在组件内获取context
4527+const context = this.getUIContext().getHostContext() as common.UIAbilityContext;
4528+ 
4529+const phoneNumber = '13812345678';
4530+const minDuration = 60;
4531+// 调用接口查询,默认查询6小时以内的通话记录
4532+contact.hasMatchedCallLog(context, phoneNumber, minDuration).then((hasMatch:boolean) => {
4533+ console.info(`Has matched call log: ${hasMatch}`);
4534+});
4535+```
4536+ 
4420## ContactSelectionOptions<sup>10+</sup>4537## ContactSelectionOptions<sup>10+</sup>
4421 4538 
4422选择联系人条件。4539选择联系人条件。