
流程说明:
用户在开发者应用上选择举报诈骗通话记录功能。
开发者应用调用Device Security Kit的接口拉起诈骗通话记录选择器。
用户在诈骗通话记录选择器中选择诈骗通话记录。
Device Security Kit调用回调函数通知开发者应用,开发者应用根据诈骗通话记录信息进行业务处理。
以下是获取诈骗通话记录相关接口,更多接口及使用方法请参见API参考。
| 接口名 | 描述 |
|---|---|
| selectFraudCallLog(context: common.Context, options?: AntifraudCallLogOptions): Promise<AntifraudCallLogResult> | 获取诈骗通话记录信息。 |
在开发准备过程中,需要申请权限:ohos.permission.USE_FRAUD_CALL_LOG_PICKER。
只允许清单内的应用申请该权限,申请方式请参考:申请使用受限权限
开发者需向用户说明数据使用的目的、方式和范围。
导入Device Security Kit模块及相关公共模块。
import { BusinessError } from '@kit.BasicServicesKit';
import antifraudPicker from '@hms.security.antifraudPicker';
import hilog from '@ohos.hilog';
import { common } from '@kit.AbilityKit'; 调用selectFraudCallLog接口获取诈骗通话记录信息。
const TAG = "AntifraudPickerJsTest";
// 请求获取诈骗通话记录信息,并进行业务处理
let options: antifraudPicker.AntifraudCallLogOptions = {
maxSelectNumber: 5
};
try {
hilog.info(0x0000, TAG, 'SelectFraudCallLog begin.');
let context = this.getUIContext().getHostContext();
const result: antifraudPicker.AntifraudCallLogResult = await antifraudPicker.selectFraudCallLog(context, options);
} catch (err) {
let e: BusinessError = err as BusinessError;
hilog.error(0x0000, TAG, 'SelectFraudCallLog failed: %{public}d %{public}s', e.code, e.message);
}