Biometric Verification SDK

Add Face ID, Touch ID, or fingerprint authentication to your app.

Written By despia

Last updated About 1 year ago

Why we add a script tag: We use this approach to ensure the authentication functions are always available, even when using no-code tools. These tools sometimes load your custom code before the page is ready, which can cause issues. Adding a script tag this way makes sure everything works correctly with builders like WeWeb, Bubble, Toddle or other no-code platforms.

SDK Usage

// 1. Add authentication scripts
if (!document.getElementById("bioauth-sdk")) {
    const script = document.createElement("script")
    script.id = "bioauth-sdk"
    script.type = "text/javascript"
    script.textContent = `
        function onBioAuthSuccess() {
            window.bioauthSuccess()
        }
        function onBioAuthFailure(errorCode, errorMessage) {
            window.bioauthFailure(errorCode, errorMessage)
        }
        function onBioAuthUnavailable() {
            window.bioauthUnavailable()
        }
    `
    document.head.appendChild(script)
}

// 2. Add your handlers
window.bioauthSuccess = function() {
    console.log("Success")
    // Run your code here
}

window.bioauthFailure = function(errorCode, errorMessage) {
    console.log("Failed:", errorCode, errorMessage)
    // Handle errors here
}

window.bioauthUnavailable = function() {
    console.log("Unavailable")
    // Handle unavailable case here
}

// 3. Start authentication
window.despia = "bioauth://"

Examples

Basic Authentication

window.bioauthSuccess = function() {
    // User is verified
    unlockApp()
}

// Start verification
window.despia = "bioauth://"

Handle Errors

window.bioauthFailure = function(errorCode, errorMessage) {
    if (errorCode === "cancelled") {
        // User cancelled
        showPasswordLogin()
    }
}

Device Not Supported

window.bioauthUnavailable = function() {
    // Show alternative login
    showPinLogin()
}

Tips

  • Always add fallback authentication

  • Handle all three callbacks

  • Test on multiple devices

  • Keep error messages simple


Need help? Email us at support@despia.com