0
0
iOS Swiftmobile~20 mins

Biometric authentication (Face ID, Touch ID) in iOS Swift - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Biometric Authentication Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
1:30remaining
What happens when biometric authentication succeeds?
In an iOS app using Face ID or Touch ID, what is the typical behavior after successful biometric authentication?
AThe app unlocks the protected content and navigates to the main screen.
BThe app closes immediately without any message.
CThe app shows an error message and asks to try again.
DThe app logs out the user automatically.
Attempts:
2 left
💡 Hint
Think about what the user expects after confirming their identity.
🧠 Conceptual
intermediate
1:00remaining
Which framework is used for biometric authentication in iOS?
Which Apple framework provides the APIs to implement Face ID and Touch ID authentication in iOS apps?
AUIKit
BCoreData
CAVFoundation
DLocalAuthentication
Attempts:
2 left
💡 Hint
It starts with 'Local' and deals with device security.
📝 Syntax
advanced
2:00remaining
What is the correct way to create a LAContext and check if biometric authentication is available?
Given the following Swift code snippet, which option correctly creates a LocalAuthentication context and checks if biometric authentication can be evaluated?
iOS Swift
import LocalAuthentication

let context = LAContext()
var error: NSError?

// Check if biometric authentication is available
let canEvaluate = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
Alet canEvaluate = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
Blet canEvaluate = context.canEvaluatePolicy(.deviceOwnerAuthentication, error: error)
Clet canEvaluate = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: error)
Dlet canEvaluate = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics)
Attempts:
2 left
💡 Hint
Check the method signature and parameter types carefully.
lifecycle
advanced
1:30remaining
What happens if biometric authentication is interrupted by app going to background?
If the user starts biometric authentication but the app goes to the background (e.g., user presses home button), what is the expected behavior?
AThe authentication succeeds immediately without user input.
BThe app crashes due to lost context.
CThe authentication is cancelled and the app must restart it when active again.
DThe authentication continues in the background automatically.
Attempts:
2 left
💡 Hint
Think about security and user interaction requirements.
🔧 Debug
expert
2:30remaining
Why does this biometric authentication code always fail with error code -7?
Consider this Swift code snippet for biometric authentication: import LocalAuthentication let context = LAContext() context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Access needed") { success, error in if success { print("Authenticated") } else { print(error?.localizedDescription ?? "Unknown error") } } The error code returned is always -7 (LAError.biometryNotAvailable). What is the most likely cause?
AThe LAContext instance must be created inside the closure.
BThe device does not have biometric hardware or it is disabled in settings.
CThe localizedReason string is missing and causes failure.
DThe evaluatePolicy method requires a completion handler on the main thread.
Attempts:
2 left
💡 Hint
Error code -7 means biometry is not available on the device.