{"id":13396486,"url":"https://github.com/velikanov/SwiftPasscodeLock","last_synced_at":"2025-03-13T23:31:22.573Z","repository":{"id":62450534,"uuid":"48254212","full_name":"velikanov/SwiftPasscodeLock","owner":"velikanov","description":"An iOS passcode lock with TouchID authentication written in Swift.","archived":false,"fork":true,"pushed_at":"2019-03-28T06:50:32.000Z","size":5210,"stargazers_count":199,"open_issues_count":27,"forks_count":52,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-30T19:17:40.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"yankodimitrov/SwiftPasscodeLock","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/velikanov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-18T20:06:05.000Z","updated_at":"2024-05-18T09:43:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/velikanov/SwiftPasscodeLock","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velikanov%2FSwiftPasscodeLock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velikanov%2FSwiftPasscodeLock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velikanov%2FSwiftPasscodeLock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/velikanov%2FSwiftPasscodeLock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/velikanov","download_url":"https://codeload.github.com/velikanov/SwiftPasscodeLock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221421546,"owners_count":16817827,"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":[],"created_at":"2024-07-30T18:00:54.887Z","updated_at":"2024-10-25T11:30:42.755Z","avatar_url":"https://github.com/velikanov.png","language":"Swift","readme":"# PasscodeLock\nA Swift implementation of passcode lock for iOS with TouchID authentication.\n\nOriginally created by [@yankodimitrov](https://github.com/yankodimitrov/SwiftPasscodeLock), hope you're doing well.\n\n\u003cimg src=\"https://raw.githubusercontent.com/yankodimitrov/SwiftPasscodeLock/master/passcode-lock.gif\" height=\"386\"\u003e\n\n## Installation\nPasscodeLock requires Swift 2.0 and Xcode 7\n\n### [CocoaPods](http://cocoapods.org/)\n\n#### Podfile\n\nTo integrate PasscodeLock into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\n\npod 'PasscodeLock', '~\u003e 1.0.2'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### [Carthage](https://github.com/Carthage/Carthage)\n\nAdd the following line to your [Cartfile](https://github.com/carthage/carthage)\n```swift\ngithub \"velikanov/SwiftPasscodeLock\"\n```\n## Usage\n\n- Create an implementation of the `PasscodeRepositoryType` protocol.\n\n```swift\nimport UIKit\nimport PasscodeLock\n\nclass PasscodeRepository: PasscodeRepositoryType {\n    \n    var hasPasscode: Bool = true\n    var passcode: [String]?\n    \n    func savePasscode(passcode: [String]) {}\n    \n    func deletePasscode() {}\n    \n}\n```\n\n- Create an implementation of the `PasscodeLockConfigurationType` protocol and set your preferred passcode lock configuration options. If you set the `maximumInccorectPasscodeAttempts` to a number greather than zero, when user will reach that number of incorrect passcode attempts a notification with name `PasscodeLockIncorrectPasscodeNotification` will be posted on the default `NSNotificationCenter`. \n\n```swift\nimport UIKit\nimport PasscodeLock\n\nclass PasscodeLockConfiguration: PasscodeLockConfigurationType {\n    let repository: PasscodeRepositoryType\n    var passcodeLength = 4 // Specify the required amount of passcode digits\n    var isTouchIDAllowed = true // Enable Touch ID\n    var shouldRequestTouchIDImmediately = true // Use Touch ID authentication immediately\n    var maximumInccorectPasscodeAttempts = 3 // Maximum incorrect passcode attempts\n    \n    init(repository: PasscodeRepositoryType) {\n        self.repository = repository\n    }\n    \n    init() {\n        self.repository = PasscodeRepository() // The repository that was created earlier\n    }\n}\n```\n\n- Create an instance of the `PasscodeLockPresenter` class. Next inside your `UIApplicationDelegate` implementation call it to present the passcode in `didFinishLaunchingWithOptions` and `applicationDidEnterBackground` methods. The passcode lock will be presented only if your user has set a passcode.\n\n- Allow your users to set a passcode by presenting the `PasscodeLockViewController` in `.SetPasscode` state:\n```swift\nlet configuration = ... // your implementation of the PasscodeLockConfigurationType protocol\n\nlet passcodeViewController = PasscodeLockViewController(state: .SetPasscode, configuration: configuration)\n\npresentViewController(passcodeViewController, animated: true, completion: nil)\n```\n\nYou can present the `PasscodeLockViewController` in one of the four initial states using the `LockState` enumeration options: `.EnterPasscode`, `.SetPasscode`, `.ChangePasscode`, `.RemovePasscode`.\n\nAlso you can set the initial passcode lock state to your own implementation of the `PasscodeLockStateType` protocol.\n\n## Customization\n\n### Custom Design\n\nThe PasscodeLock will look for `PasscodeLockView.xib` inside your app bundle and if it can't find it will load its default one, so if you want to have a custom design create a new `xib` with the name `PasscodeLockView` and set its owner to an instance of `PasscodeLockViewController` class.\n\nKeep in mind that when using custom classes that are defined in another module, you'll need to set the Module field to that module's name in the Identity Inspector:\n\n\u003cimg src=\"https://raw.githubusercontent.com/yankodimitrov/SwiftPasscodeLock/master/identity-inspector.png\"\u003e\n\nThen connect the `view` outlet to the view of your `xib` file and make sure to conenct the remaining `IBOutlet`s and `IBAction`s.\n\nPasscodeLock comes with two view components: `PasscodeSignPlaceholderView` and `PasscodeSignButton` that you can use to create your own custom designs. Both classes are `@IBDesignable` and `@IBInspectable`, so you can see their appearance and change their properties right inside the interface builder:\n\n\u003cimg src=\"https://raw.githubusercontent.com/yankodimitrov/SwiftPasscodeLock/master/passcode-view.png\" height=\"270\"\u003e\n\n### Localization\n\nTake a look at `PasscodeLock/en.lproj/PasscodeLock.strings` for the localization keys. Here again the PasscodeLock will look for the `PasscodeLock.strings` file inside your app bundle and if it can't find it will use the default localization file.\n\n## Demo App\n\nThe demo app comes with a simple implementation of the `PasscodeRepositoryType` protocol that is using the **NSUserDefaults** to store and retrieve the passcode. In your real applications you will probably want to use the **Keychain API**. Keep in mind that the **Keychain** records will not be removed when your user deletes your app.\n","funding_links":[],"categories":["UI"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvelikanov%2FSwiftPasscodeLock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvelikanov%2FSwiftPasscodeLock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvelikanov%2FSwiftPasscodeLock/lists"}