Skip to content
This repository has been archived by the owner on Sep 22, 2019. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

liamnichols/UIDevice-PasscodeStatus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UIDevice-PasscodeStatus

Update

As of iOS 9, you can achieve this using the LocalAuthentication.framework. If targeting iOS 9+ read the comments here or look at this answer.

If you still need to target iOS 8 then continue reading :)


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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •