Closed szh closed 8 years ago
Would appreciate some more feedback on this, perhaps a PR?
I released a new version and added some more tests to cover this. It works fine here, the error callback should always be called, please test and let me know if it still fails for you.
Thanks for the quick response. I went ahead and ran the tests, and they do pass. Unfortunately it's very hard to reproduce this error. It usually happens when I launch the app, in case that helps. I actually have code in my error handler to try to catch the error but it seems to either skip it or maybe it throws the error even after the handler is called:
this.ss.get((val) => resolve(val), (e) => {
if (String(e).includes("errSecItemNotFound")) {
resolve(null); // Item not found in Keychain
} else {
reject(e);
}
}, key);
I am guessing you do wait for deviceready
before everything?
With regards to the snippet: SecureStorage.get will reject if it does not find a value. You can of course catch that and return null instead, but does it ever return null when there is no such item?
Yes, I'm waiting for deviceready. You're right, it doesn't return null. I thought it was, b/c I was handling that in code elsewhere in my app. I guess there's really no way to fix this if we can't reproduce it. I'll report back if I have more details that could help.
When an item isn't present in the iOS keychain, usually
get()
returns null, but sometimes it throws "errSecItemNotFound".