iOS 15 keychain data retrieve issue

After upgrading to iOS 15, when I open the app after a couple of hours, we are not able to retrieve keychain data in didFinishLaunchingWithOptions delegate method. For each new launch we are facing the same issue of of not retrieving keychain data. We need to relogin to process further in the application. But for iOS 14 and below we are not facing this issue, we are able to retrieve the keychain data in didFinishLaunchingWithOptions delegate. Is anyone facing the same issue in their application?

Replies

Yes, we're currently facing the same issue, I actually posted a very similar question. Hopefully we can get to the bottom of this

Have the same issue. But I found strange app behaviour on iOS 15.0. When the iPhone screen is locked and the app was closed(terminated), in 10 minutes iOS 15 opens it automatically in the background mode (didFinishLaunchingWithOptions, UIApplication.shared.applicationState == .background, the screen is still locked), keychain returns null, the app starts sending requests to my server (see requests in the Charles proxy).

Then when I unlock the screen, I don't see that my app is in the background mode, but when I tap on the app icon, the app opens, didFinishLaunchingWithOptions is not called.

Tested on iOS 15.1. Print logs into UserDefaults. Maybe somebody knows how to disable this background feature?

  • Update: Found root cause. In my case, the background push notification opens the closed app in  .background mode, sometimes keychain in the didFinishLaunchingWithOptions method returns nill instead of my tokens.

  • Did anyone find solution to this ? We face the same issue where keychain doesnt return the values occationally causing registration removal.

  • Hi @VictorVl, how did you replicated this issue? We do face similar issue and looking for replicating the problem in physical device.

There are some changes in app launch behavior with "prewarm", which can lead to problems with keychain. Check this article and documentation: https://sourcediving.com/solving-mysterious-logout-issues-on-ios-15-8b818c089466 https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app/about_the_app_launch_sequence#3894431