iOS 15 Keychain Storage is clearing when app is in background for some time

Hey! This is my first question on the developer forums so please bare with me incase I'm doing something wrong. To cut to the chase, my team recently updated their iOS devices to iOS 15 and we've encountered a strange issue.

If our app is left backgrounded for a while (couple of hours), KeychainStorage is clearing out the stored values. We've confirmed this only happens on iOS 15+ devices since users with iOS 14 are not facing any issues.

We are storing the access token/refresh token of the user in Keychain and basically, if the user doesn't open the app for a while, they automatically get logged out (definitely not a nice UX).

I've checked online, and many people were suggesting that Keychain data requires time to be decrypted but I made sure I'm not accessing the data prior to the decryption. Also, I made sure that nothing is called before didFinishLaunchingWithOptions.

Our kSecAttrAccessible is set to kSecAttrAccessibleWhenUnlockedThisDeviceOnly if that's of any use.

I've seen other posts regarding this issue but all other cases seemed to be resolved by waiting for a notification that data became available, again, I'm not facing that problem.

If any more info is required, please let me know and I'll be sure to reply ASAP.

Replies

Did you find out the reason for this issue ? We have similar issue and looking for some guidance.