Skip to content

ios-utils/UnlockCodeViewController

Repository files navigation

UnlockCodeViewController

A simple drop-in Unlock Code view controller.

Codacy Badge CodeCov Badge Build Status Docs Badge Version License Platform

UnlockCodeViewController

Usage

Basic Usage

// Create the view controller
let viewController = UnlockCodeViewController(unlockCode: myCode)

// Present the view controller
navigationController.setViewControllers([viewController], animated: false)

// Set the unlock action (this can also be set in the constructor)
viewController.whenUnlocked { _ in
    navigationController.setViewControllers([myLockedContentViewController], animated: true)
}

Additional Config

// (Optional) Additional config
viewController.pinCharacter = "*"           // default: "●"
viewController.blankCharacter = "_"         // default: "○"
viewController.playsSound = false           // default: `true`
viewController.autoDismissOnUnlock = false  // default: `false`
viewController.autoDismissOnFailure = true  // default: `false`
viewController.maxAttemptsAllowed = 5       // default: 3

Generating an UnlockCode

  • Ideally you would set the unlock code remotely, and load it into your app.
  • Then next best option would be to use a pre-generated code. Otherwise anyone can decompile your application and read your code in plaintext.
// Using a pre-generated code (e.g. "123456")
let myCode = UnlockCode(
    hash: "2DBD6C5C6085CB173C76E0856CF2EB85DB6A464264704528187E18A808A0D569",
    salt: "O%0jc@_Qy)gAa9d",
    length: 6,
    isNumeric: true
)

// Or generate one on the fly (*Not Recommended*)
let myGeneratedCode = UnlockCode(generateFor: "123456")

Documentation

Complete documentation is available online.

Example Project

To run the example project, clone the repo, and run in Xcode 10 or greater.

Installation

CocoaPods

UnlockCodeViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'UnlockCodeViewController'

Author

Reece Como, reece.como@gmail.com

License

UnlockCodeViewController is available under the MIT license. See the LICENSE file for more info.

About

A simple drop-in Unlock Code view controller

Resources

License

Stars

Watchers

Forks

Packages

No packages published