Latest 0.0.2
Homepage https://github.com/liamnichols/UIDevice-PasscodeStatus
License MIT
Platforms ios , requires ARC
Frameworks Security
Authors

A UIDevice category to determine if the passcode is currently set on the device or not.

Requirements

  • iOS 8
  • A Physical Device

How it Works

This category works by using the new accessControl features added to the Security.Framework in iOS 8.
It attempts to add an item to the keychain using the kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly protection level.

The documentation states the following:

Item data can only be accessed while the device is unlocked. This class is only
available if a passcode is set on the device. This is recommended for
items that only need to be accessible while the application is in the
foreground. Items with this attribute will never migrate to a new
device, so after a backup is restored to a new device, these items
will be missing. No items can be stored in this class on devices
without a passcode.
Disabling the device passcode will cause all
items in this class to be deleted.

Because of this, an error is returned when you attempt to add or read an item in the keychain with this level of accessControl. If we see this error, the passcodeStatus returns as LNPasscodeStatusDisabled.
If we can successfully read or write to the keychain with this level of accessControl then we return LNPasscodeStatusEnabled.

If the device is unsupported or an unrelated error with the keychain is returned, we return LNPasscodeStatusUnknown.

Installation

CocoaPods:
pod 'UIDevice-PasscodeStatus', '~> 0.0.2'

Manually:
Just copy the category from the Source/ directory into your project and import Security.Framework

Latest podspec

{
    "name": "UIDevice-PasscodeStatus",
    "version": "0.0.2",
    "summary": "A UIDevice category to determine if the passcode is currently set on the device or not.",
    "homepage": "https://github.com/liamnichols/UIDevice-PasscodeStatus",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Liam Nichols": "[email protected]"
    },
    "social_media_url": "http://twitter.com/liamnichols_",
    "platforms": {
        "ios": null
    },
    "source": {
        "git": "https://github.com/liamnichols/UIDevice-PasscodeStatus.git",
        "tag": "0.0.2"
    },
    "source_files": "Source/*.{h,m}",
    "frameworks": "Security",
    "requires_arc": true
}

Pin It on Pinterest

Share This