Assume a following situation:
- User restarts his/her iPhone.
- User lets device locked, does not unlock it.
- Server sends a (silent) push notification on the device (or anything happens that wakes the application up on the background, such as Apple Watch extension requests data, etc.).
- App wakes up and tries to access Keychain items stored with
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
accessibility.
Now, the Keychain items should not be accessible, since device was not unlocked yet. How do I correctly check for this situation?
Note: In my case, the presence of an item stored in the keychain determines if the app is "active" or not, so I would need something to stop this check soon enough, otherwise my app will assume it's not active (value cannot be read) and perform init steps...
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
flag and try to read it back immediately), clever! Thank you. – Indonesian