I'm running an iOS app via a debugger on my iPhone 5s. I'm using the keychain to store a password (I'm using the KeychainItemWrapper example from Apple to store and retrieve my keychain items). About 99.99% of the time, the keychain retrieval works perfectly. However, there have been two cases in which my application could not get the password. For example, once, my phone was experiencing memory pressure and I had to restart the phone and relaunch the app. Upon the app relaunch, my app could no longer retrieve the password from the keychain. I wonder if this password loss was caused by this memory pressure? What other cases does iOS purge keychain data? Is there any way to present this??
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
iOS keychain is very much unrelated with your app's memory pressure.
There could be 2 scenarios:
- Somehow you happen to reset your phone - Keychain data would be lost (unless your keychain is synced with icloud).
- You somehow called
resetKeychainItem
from your wrapper.
Can't help more without having a look at your code.
回答2:
You could probably not found the value temporary, as you can see in this question: KeychainItemWrapper not getting loaded on iOS 9 OSStatus -34018 (errSecMissingEntitlement) and the related question on apple's forum: https://forums.developer.apple.com/thread/4743