目录

Obtaining Fraudulent Call Logs

Use Cases

An app calls the API of Device Security Kit to obtain fraudulent call logs for anti-fraud purposes, such as reporting fraudulent call logs.

Constraints

Currently, this capability is supported only on phones and tablets. It is available only to anti-fraud apps.

Service Process

Process description:

  1. A user selects the function of reporting fraudulent call logs in your app.

  2. Your app calls the API of Device Security Kit to start the fraudulent call log picker.

  3. The user selects fraudulent call logs in the fraudulent call log picker.

  4. Device Security Kit calls the callback function to notify your app of the selection result. Your app then processes the service based on the fraudulent call log information.

API Description

The following table lists the API for obtaining fraudulent call logs. For more information about the API, please refer to API Reference.

API Description
selectFraudCallLog(context: common.Context, options?: AntifraudCallLogOptions): Promise<AntifraudCallLogResult> Obtains fraudulent call logs.

Development Procedure

  • When preparing for the development, you need to apply for the ohos.permission.USE_FRAUD_CALL_LOG_PICKER permission.

  • Only apps in the trustlist can apply for this permission. For details about how to apply for this permission, please refer to Requesting Restricted Permissions.

  • You need to inform users about the purpose, methods, and scope of data usage.

  1. Import the Device Security Kit module and related public modules.

    import { BusinessError } from '@kit.BasicServicesKit';
    import antifraudPicker from '@hms.security.antifraudPicker';
    import hilog from '@ohos.hilog';
    import { common } from '@kit.AbilityKit';
  2. Call the selectFraudCallLog API to obtain the fraudulent call log information.

    const TAG = "AntifraudPickerJsTest";
    
    // Request to obtain the fraudulent call log information and process the service.
    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);
    }