Example SwiftUI App to sign in with Apple and Biometrics (FaceID).
With the app, I wanted to acquire the knowledge of how registration works with AppleID and Biometrics. The app still needs improvement at various points, these will be implemented over time. The biggest challenge was the handling of the edge cases (no internet connection, access not allowed, etc.). However, it was a lot of fun and I will use this in my private project.
- First Login: Sign in with Apple
- Second Login: also via Biometrics possible
- Coldstart: if the user is already logged in with the Apple ID, the login screen can be bypassed when the user opens the app for the second time
- Warmstart: same screen state as before (should be show the Login Screen after x minutes, see Todo´s)
- Some unit tests and ui tests
- Logout possible
This project does not contain any dependencies. Just try the project and launch it on your device. To test on your device, you need a provisioning profile with "Sign in to Apple" enabled.
- create constants for texts
- create color constants
- storage user data into keychain, not in user defaults (not secure!)
- Check what happens when the user logs out (in the iPhone Settings), and register with a new one...
- create User Settings (register with Biometrics should be enabled/disabled by the user)
- Write more unit and UI tests
- Warmstart: how long is the session valid? Using credential.identityToken?
- sign with existing account: credential realUserStatus - instead treat them as any new user through standard email sign up flows
- AppleId: maybe use nonce and state to prevent replay attacks
Here you can find some testing scenarios. You can also test no internet connection e.g. Airline mode active.
Note that the user can disable the use of Face ID and Apple ID at any time in the iPhone settings.
GIVEN Login Screen is visible
WHEN sign in with Apple
WHEN click on Cancel
THEN Login Screen is still visible without any error message\
GIVEN logged in user with AppleId.
AND never try with FaceId (new installation - should not displayed in the iPhone App Setting)
WHEN coldstart
WHEN system message will appear "may i use Face-ID?"
WHEN dont allow
THEN Login screen appears with only one message 'you can skip the manual login process by approving..."\
GIVEN allready logged in user with biometrics
WHEN go to the settings and disable Login with biometrics
WHEN login again with Apple-ID
WHEN logout
THEN LoginScreen should be displayed without any error messages\
