Skip to main content
Use this API to check if biometric authentication (fingerprint or face recognition) is available on the device.

Parameters

PropertyTypeRequiredDescription
successFunctionNoCallback on success
failFunctionNoCallback on failure
completeFunctionNoCallback that always executes

Success Callback Parameters

PropertyTypeDescription
availableBooleanWhether biometric is available
typeStringAvailable type: fingerPrint, facial, or none

Code Example

Basic Usage

my.checkLocalBioAuthSupported({
  success(res) {
    console.log('Biometric available:', res.available);
    console.log('Type:', res.type);
  }
});

Conditional UI

Page({
  data: {
    biometricAvailable: false,
    biometricType: 'none'
  },

  onLoad() {
    my.checkLocalBioAuthSupported({
      success: (res) => {
        this.setData({
          biometricAvailable: res.available,
          biometricType: res.type
        });
      }
    });
  }
});

Smart Authentication

Page({
  authenticate() {
    my.checkLocalBioAuthSupported({
      success: (res) => {
        if (res.available) {
          this.useBiometric(res.type);
        } else {
          this.usePasswordAuth();
        }
      }
    });
  },

  useBiometric(type) {
    const title = type === 'facial'
      ? 'Look at your device'
      : 'Touch the fingerprint sensor';

    my.startLocalBioAuth({
      type: type,
      title: title,
      success: (res) => {
        if (res.success) {
          this.onAuthSuccess();
        }
      },
      fail: () => {
        // Fall back to password
        this.usePasswordAuth();
      }
    });
  },

  usePasswordAuth() {
    // Show password input
  },

  onAuthSuccess() {
    // Proceed with authenticated action
  }
});

Display Biometric Options

Page({
  data: {
    authMethods: []
  },

  onLoad() {
    const methods = [{ name: 'Password', type: 'password' }];

    my.checkLocalBioAuthSupported({
      success: (res) => {
        if (res.available) {
          if (res.type === 'fingerPrint') {
            methods.unshift({ name: 'Fingerprint', type: 'fingerPrint' });
          } else if (res.type === 'facial') {
            methods.unshift({ name: 'Face ID', type: 'facial' });
          }
        }
        this.setData({ authMethods: methods });
      }
    });
  }
});
Always check biometric availability before showing biometric options in your UI to avoid confusing users on devices without biometric capabilities.

my.startLocalBioAuth

Start biometric verification