Open ablkenny opened 6 years ago
Seeing the same thing on Swift 4
Same issue on Swift 3.2.
@ablkenny Did you find a pattern?
hey @ablkenny @nicopuri I saw this issue recently and realized that the keychain is specific to the applications 'identifier entitlement'.
In simple terms, the build I run on test flight with a production provisioning profile does not have access to the same keychain data as if I do a local dev build with a dev provisioning profile. However, there may be more cases that could trigger this same issue, I'm not sure.
Perhaps this is related to this problem you are experiencing
I too experience the same issue, any take on how to fix it?
I did not managed to resolve this issue. What I did was to migrate keychain data into core data with additional encryption.
Not sure if this is the right approach. Will try to do more investigation and update here again
Same. The data of encoded Array is not storred. Trying the lib, @zapjonny mentioned. ... Tried. This lib is better for use. Made it work. Take sure, that u use
KeychainWrapper.standard.set(encoded, forKey: "")
let archivedData = KeychainWrapper.standard.data(forKey: "")
Hi, I use this lib and I can find error like you. I found the pattern like this.
1. app terminated and start
2. app on background for a long time (on background after 3~4 hours)
3. iOS 11+
I saw my code again and again, but I can't find error logic.. :(
My environment
I recommend checking out the Valet api by Square. https://github.com/square/Valet
@logansease Valet api ? what is that?
@hyesunzzang https://github.com/square/Valet
I change the lib https://github.com/kishikawakatsumi/KeychainAccess but it happens again.. 😢
This is still a problem, it keeps making my user to logged out when I tried to store their data in keychain, I thought it was the accessibility problem, so I changed it to .afterFirstUnlock, still missing. Gonna change to Valet to see if it works.
The build has problem is the Testflight build, I'm running iOS 13 in iPhone XS, but it might happen with any other device
You may be encountering a situation where protected data is not yet available. Under some rare circumstances your app may be launched (perhaps from a push notification) and UIApplication.shared.isProtectedDataAvailable
returns false. If this happens you will not be able to access values stored in the Keychain (or UserDefaults)
Thanks, sound like exactly what Im facing, my app indeed have a lot background wake, is there anyway to overcome this?
Yes. Always check UIApplication.shared.isProtectedDataAvailable in your appDelegate's application:didFinishLaunchingWithOptions before trying to access Keychain or UserDefaults. If protected data is not available and you require it, you could try to delay / defer startup in some way (such as Timer or asyncAfter)
Some more reading: https://stackoverflow.com/questions/43125168/ios-app-startup-and-protected-data-events https://stackoverflow.com/questions/48002584/how-to-process-tap-on-push-notification-banner-at-password-locked-ios-device https://medium.com/@bohan_66764/dont-let-nsuserdefaults-betrayed-you-ccaa41013592
I try solve this problem, but I can't so I SwiftKeychainWrapper replace to SQLite.
For some reason, Vallet lib seems to completely solved this issue for me. If anyone have this problem try switch to it.
hi guys, i am having issues using KeychainWrapper in Swift 3.1.
everything was fine in the beginning. but after a period of time, data stored in keychain is lost and unable to retrieve.
I had stored the data with the default accessibility (.whenUnlocked), and attempt to retrieve using the same accessibility while the app is in foreground.
The issue is quite random as not all iphone devices encounter it.
Does anyone encountered this issue before? Any solution or is keychain stable to use?