How to Localize Biometric Prompt for SecKeyCreateSignature with Secure Enclave

I'm using Secure Enclave to generate and use a private key like this:

let access = SecAccessControlCreateWithFlags(nil,
    kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
    [.privateKeyUsage, .biometryAny],
    nil)

let attributes: [String: Any] = [
    kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom,
    kSecAttrKeySizeInBits as String: 256,
    kSecAttrTokenID as String: kSecAttrTokenIDSecureEnclave,
    kSecAttrAccessControl as String: access as Any,
    kSecAttrApplicationTag as String: "com.example.key".data(using: .utf8)!,
    kSecReturnRef as String: true
]

let privateKey = SecKeyCreateRandomKey(attributes as CFDictionary, nil)

Later, I use this key to sign a message:

let signature = SecKeyCreateSignature(privateKey, .ecdsaSignatureMessageX962SHA256, dataToSign as CFData, nil)

This prompts for biometric authentication, but shows the default system text.

How can I customize or localize the biometric prompt (e.g., title, description, button text) shown during SecKeyCreateSignature?

Thanks!

Accepted Answer

NVM I found the solution.

let context = LAContext()
context.localizedReason = "Authenticate to sign your transaction"  // Main prompt text
context.localizedCancelTitle = "Cancel"  // Cancel button text
context.localizedFallbackTitle = "Use Passcode"

// While fetching the private key pass the context
let query: [String: Any] = [
    kSecClass as String: kSecClassKey,
    kSecAttrApplicationTag as String: "com.example.key".data(using: .utf8)!,
    kSecReturnRef as String: true,
    kSecUseAuthenticationContext as String: context  // Associate the context
]

How to Localize Biometric Prompt for SecKeyCreateSignature with Secure Enclave
 
 
Q