{"id":1934,"url":"https://github.com/rushisangani/BiometricAuthentication","last_synced_at":"2025-08-02T05:33:10.070Z","repository":{"id":46573754,"uuid":"108635648","full_name":"rushisangani/BiometricAuthentication","owner":"rushisangani","description":"Use Apple FaceID or TouchID authentication in your app using BiometricAuthentication.","archived":false,"fork":false,"pushed_at":"2021-10-05T07:58:28.000Z","size":322,"stargazers_count":831,"open_issues_count":16,"forks_count":110,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-29T21:01:11.077Z","etag":null,"topics":["apple","apple-faceid","authentication","biometric","biometric-identification","biometricauthentication","biometrics","face","facedetection","faceid","facerecognition","fingerprint","fingerprint-authentication","localauthentication","passcode-authentication","swift-4","swift5","touchid","touchid-authentication"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rushisangani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-28T09:16:04.000Z","updated_at":"2024-10-12T12:25:26.000Z","dependencies_parsed_at":"2022-08-21T02:50:11.238Z","dependency_job_id":null,"html_url":"https://github.com/rushisangani/BiometricAuthentication","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FBiometricAuthentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FBiometricAuthentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FBiometricAuthentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FBiometricAuthentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rushisangani","download_url":"https://codeload.github.com/rushisangani/BiometricAuthentication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228443740,"owners_count":17920779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple","apple-faceid","authentication","biometric","biometric-identification","biometricauthentication","biometrics","face","facedetection","faceid","facerecognition","fingerprint","fingerprint-authentication","localauthentication","passcode-authentication","swift-4","swift5","touchid","touchid-authentication"],"created_at":"2024-01-05T20:15:59.327Z","updated_at":"2024-12-06T09:30:40.242Z","avatar_url":"https://github.com/rushisangani.png","language":"Swift","readme":"# BiometricAuthentication\nUse Apple FaceID or TouchID authentication in your app using BiometricAuthentication.\nIt's very simple and easy to use that handles Touch ID and Face ID authentication based on the device.\n\n**Note:** - Face ID authentication requires user's persmission to be add in info.plist.\n```swift\n\u003ckey\u003eNSFaceIDUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app requires Face ID permission to authenticate using Face recognition.\u003c/string\u003e\n```\n\n### What's new in version 3.1\n- Updated to Swift 5.0\n- Implemented **Result** type as completion callback\n\n### Version 2.2\n- Set **AllowableReuseDuration** (in seconds) to auto authenticate when user has just unlocked the device with biometric.\n- This is pretty useful when app comes to foreground or device is just unlocked by the user and you want to authenticate with biometrics.\n- If you don't want to reuse the recently used authentication then simply skip this step.\n```swift\n\n// set this before calling authenticateWithBioMetrics method (optional)\nBioMetricAuthenticator.shared.allowableReuseDuration = 60\n```\n\n### Version 2.1\n- Check if **TouchID**  or **FaceID** authentication is available for iOS device.\n\n\n![Alt text](https://raw.githubusercontent.com/rushisangani/BiometricAuthentication/master/Images/image1.png \"Authenticate\")\n![Alt text](https://raw.githubusercontent.com/rushisangani/BiometricAuthentication/master/Images/image2.png \"Fallback title\")\n![Alt text](https://raw.githubusercontent.com/rushisangani/BiometricAuthentication/master/Images/image3.png \"Locked out\")\n\n## Features\n\n- Works with Apple Face ID (iPhone X, Xs, XR, XsMax) and other Touch ID having devices.\n- Predefined error handling when recognition fails.\n- Automatic authentication with device passcode on multiple failed attempts.\n\n## Requirements\n\n- iOS 12.0+\n- Xcode 10+\n- Swift 3.0+\n\n## Installation\n\n### CocoaPods\n\n```ruby\npod 'BiometricAuthentication'\n```\n\n### Carthage\n\n```ruby\ngithub \"rushisangani/BiometricAuthentication\"\n```\n\n## Usage\n\n### Authenticate with biometric\n\n```swift\nBioMetricAuthenticator.authenticateWithBioMetrics(reason: \"\") { (result) in\n\n    switch result {\n    case .success( _):\n        print(\"Authentication Successful\")\n    case .failure(let error):\n        print(\"Authentication Failed\")\n    }\n}\n```\n- When reason specified as empty - default will be used based on the device. Ex. for iPhone X - **\"Confirm your face to authenticate.\"**,  For other devices - **\"Confirm your fingerprint to authenticate.\"**\n\n### Can Authenticate with biometric\n\n- Alternatively you can check before authentication by following. This will check that if device supports Touch ID or Face ID authentication and your app can use that as of now.\n\n```swift\nif BioMetricAuthenticator.canAuthenticate() {\n\n    BioMetricAuthenticator.authenticateWithBioMetrics(reason: \"\") { (result) in\n        // check result -\u003e success or failure\n    }\n}\n```\n### Check for Face ID\n- Check if device supports face recognition or not.\n```swift\nif BioMetricAuthenticator.shared.faceIDAvailable() {\n    // device supports face id recognition.\n}\n```\n### Check for Touch ID\n- Check if device supports touch id authentication or not.\n```swift\nif BioMetricAuthenticator.shared.touchIDAvailable() {\n    // device supports touch id authentication\n}\n```\n\n### Fallback Reason\n- Fallback reason title will be shown when first authentication attempt is failed.\n- You can give alternate authentication options like enter 'username \u0026 password' when user clicks on fallback button.\n- Default reason is empty, which will hide fallback button.\n\n```swift\nBioMetricAuthenticator.authenticateWithBioMetrics(reason: \"Biometric Authentication\", fallbackTitle: \"Enter Credentials\") { (result) in\n\n    switch result {\n    case .success( _):\n        // proceed further\n\n    case .failure(let error):\n\n        switch error {\n        case .fallback:\n\n            print(\"Authentication Failed\")\n\n            // show alternatives on fallback button clicked\n            // for ex. - enter username/email and password\n\n        default:\n            break\n        }\n    }\n}\n```\n\n### BiometryLockedout\n- When biometry authentication is locked out after multiple failed attempts. You can unlock it by passcode authentication.\n- Provide your own passcode authentication reason here, default will be used if not provided.\n\n```swift\nBioMetricAuthenticator.authenticateWithPasscode(reason: message) { (result) in\n    switch result {\n    case .success( _):\n        // passcode authentication success\n    case .failure(let error):\n        print(error.message())\n    }\n}\n```\n\n### Error Handling\n- There are various cases when biometric authentication can be failed.\n\n1. **fallback**\n    - Called when user clicks on provided fallback button.\n2. **biometryNotEnrolled**\n    - Called when no fingerprints or face is registered with the device.\n    - You can show message to register a new face or fingerprint here.\n    - Default message will be shown if not provided.\n3. **canceledByUser**\n    - Called when authentication canceled by user.\n4. **canceledBySystem**\n    - Called when authentication canceled by system when app goes into background or any other reason.\n5. **passcodeNotSet**\n    - Called when device passcode is not set and trying to use biometry authentication.\n    - We can ask user to set device passcode here by opening Settings Application.\n6. **failed**\n    - Called when multiple failed attempts made by user.\n    - You can show error message to user here.\n    - Default message can be shown if not provided.\n7. **biometryLockedout**\n    - Called when more than 5 failed attempts made using biometric authentication. This will locked your biometry system.\n    - You'll restrict user when this error is occured.\n    - Aleternatively you can ask user to enter device passcode to unlock biometry.\n8. **biometryNotAvailable**\n    - Called when device does not support Face ID or Touch ID authentication.\n\n### Example\n\n```swift\nBioMetricAuthenticator.authenticateWithBioMetrics(reason: \"\") { [weak self] (result) in\n\n    switch result {\n    case .success( _):\n\n        // authentication successful\n        self?.showLoginSucessAlert()\n\n    case .failure(let error):\n\n        switch error {\n\n        // device does not support biometric (face id or touch id) authentication\n        case .biometryNotAvailable:\n            self?.showErrorAlert(message: error.message())\n\n        // No biometry enrolled in this device, ask user to register fingerprint or face\n        case .biometryNotEnrolled:\n            self?.showGotoSettingsAlert(message: error.message())\n\n        // show alternatives on fallback button clicked\n        case .fallback:\n            self?.txtUsername.becomeFirstResponder() // enter username password manually\n\n        // Biometry is locked out now, because there were too many failed attempts.\n        // Need to enter device passcode to unlock.\n        case .biometryLockedout:\n            self?.showPasscodeAuthentication(message: error.message())\n\n        // do nothing on canceled by system or user\n        case .canceledBySystem, .canceledByUser:\n            break\n\n        // show error for any other reason\n        default:\n            self?.showErrorAlert(message: error.message())\n        }\n    }\n}\n```\nSee [Example](https://github.com/rushisangani/BiometricAuthentication/tree/master/BiometricAuthenticationExample) for more details.\n\n## License\n\nBiometricAuthentication is released under the MIT license. [See LICENSE](https://github.com/rushisangani/BiometricAuthentication/blob/master/LICENSE) for details.\n\n","funding_links":[],"categories":["Security","OOM-Leaks-Crash"],"sub_categories":["Unofficial","Other free courses","Gesture-Biometric Unlock"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frushisangani%2FBiometricAuthentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frushisangani%2FBiometricAuthentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frushisangani%2FBiometricAuthentication/lists"}