Verify that the iOS device is first unlocked to determine if items stored with kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly are available

Suppose the following situation:

  • The user restarts his iPhone.
  • The user allows you to lock the device, does not unlock it.
  • The server sends a (quiet) push notification to the devices (or something happens that wakes the application to the background, for example, Apple Watch renewal request data, etc.).
  • The application wakes up and tries to access Keychain items saved using the kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly accessibility.

Keychain items should no longer be available since the device is not yet unlocked. How to check this situation?

Note. In my case, the presence of an element stored in the keychain determines whether the application is β€œactive” or not, so I need something to stop this check soon enough, otherwise my application will consider it inactive (the value cannot be read) and execute the init steps ...

+5
source share

Source: https://habr.com/ru/post/1259775/


All Articles