Salesforce can prompt users to verify their identity using biometrics scanning through mobile devices. The outcome of these biometrics-related operations is sent back to the Lightning Web Component that initiated it.
The mobile device manages biometric checks locally—no network connection is required. However, for BiometricsService to function, platform-specific APIs accessible only through compatible Salesforce mobile applications are needed.
Read on to find out how to safeguard your Salesforce mobile apps through BiometricsService.
The BiometricsService API in Salesforce enables Lightning Web Components to utilize native biometrics functionality, enhancing security and providing a user-friendly experience.
Users can confirm their identity with a quick scan, eliminating the need to remember and enter complex passwords.
Operating only within compatible Salesforce mobile apps, it guarantees industry standards compliance and local device processing – and it provides a smooth interaction with Lightning Web Components for swift identity verification.
To create a Lightning Web Component with biometrics capabilities, Developers should utilize the BiometricsService API. The API must be imported into the component's JavaScript file using the standard import statement.
Developers can obtain an instance by employing the "getBiometricsService()" factory function from the "lightning/mobileCapabilities" module.
Availability should be verified using utility functions and constants, enabling feature functions to prompt users for biometrics checks, thus enhancing security within the Salesforce environment.
👉 "biometricsExample.html"
<template>
<lightning-card title="Biometrics Service Demo" icon-name="custom:privately_shared">
<div class="slds-var-m-around_medium">
Use device biometrics capabilities to verify current user is indeed device owner:
<lightning-button
variant="brand"
label="Verify"
title="Verify device ownership using biometrics"
onclick={handleVerifyClick}
class="slds-var-m-left_x-small">
</lightning-button>
</div>
<div class="slds-var-m-around_medium">
<lightning-formatted-text value={status}></lightning-formatted-text>
</div>
</lightning-card>
</template>
👉 "biometricsExample.js"
import { LightningElement } from 'lwc';
import { getBiometricsService } from 'lightning/mobileCapabilities';
export default class BiometricsExample extends LightningElement {
status;
biometricsService;
connectedCallback() {
this.biometricsService = getBiometricsService();
}
handleVerifyClick() {
if (this.biometricsService.isAvailable()) {
const options = {
permissionRequestBody: "Required to confirm device ownership.",
additionalSupportedPolicies: ['PIN_CODE']
};
this.biometricsService.checkUserIsDeviceOwner(options)
.then((result) => {
if (result === true) {
this.status = "✔ Current user is device owner."
} else {
this.status = "𐄂 Current user is NOT device owner."
}
})
.catch((error) => {
// Handle errors
this.status = 'Error code: ' + error.code + '\nError message: ' + error.message;
});
} else {
// service not available
this.status = 'Problem initiating Biometrics service. Are you using a mobile device?';
}
}
}
By utilizing built-in biometrics features, the BiometricsService API integration with Salesforce mobile apps provides enhanced security measures. This improves the user-friendliness of identity verification while guaranteeing compliance with industry standards, local device processing, and smooth integration with Lightning Web Components.