Biometric Authentication
Connected App Configuration
To configure biometric authentication, go to your org’s connected app.
- Add a custom attribute to your connected app with the key ENABLE_BIOMETRIC_AUTHENTICATION.
- To change the timeout period, add the BIOMETRIC_AUTHENTICATION_TIMEOUT key. You can adjust its value to the number of minutes that you want the app to be backgrounded for before it locks. If you choose not to add this key, the default value is set for 15 minutes.
API and Customization
To manage biometric opt-in from within the app, use SalesforceSDKManager to get the BiometricAuthenticationManager instance. You can use this instance to:
- Check whether the user has opted in to biometric authentication.
- Prompt the user to opt in or out of biometric authentication and update the SDK with their response.
- Check whether the app is locked.
- Lock the app immediately.
- Disable the native biometric unlock button entirely.
To opt the user in to biometric authentication, you can use the Mobile SDK-provided prompts or create your own.
To use the Mobile SDK-provided prompts, implement one of these lines.
- Android (Kotlin)
-
1SalesforceSDKManager.getInstance().biometricAuthenticationManager.presentOptInDialog(fragmentManager) - iOS (Swift)
-
1SalesforceManager.shared.biometricAuthenticationManager().presentOptInDialog(viewController: viewController)
If you choose to create a custom prompt, implement one of these lines to pass the user’s response to Mobile SDK.
- Android (Kotlin)
-
1SalesforceSDKManager.getInstance().biometricAuthenticationManager.biometricOptIn(userResponse) - iOS (Swift)
-
1SalesforceManager.shared.biometricAuthenticationManager().biometricOptIn(optIn: userResponse)
If the user enables biometric authentication, a native button is added to the login screen so that they can trigger the OS prompt.
To create a custom button within the app’s web view, you can use an API found in BiometricAuthenticationManager to disable the native button. Then, configure the button to redirect to mobilesdk://biometric/authentication/prompt. Mobile SDK automatically ignores this redirect and presents the native OS prompt.