Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

iOS storage retrieval issue #116

Open
gurtejsmartdata opened this issue Apr 5, 2023 · 8 comments
Open

iOS storage retrieval issue #116

gurtejsmartdata opened this issue Apr 5, 2023 · 8 comments

Comments

@gurtejsmartdata
Copy link

hi I have issue in accessing encrypted storage on iOS, I get "code":"-25308","message":"RNEncryptedStorageError: An error occurred while retrieving value" randomly . Kindly suggest the solution for it

@billnbell
Copy link

I am getting this too on IOS. Seems like we need a fix.

@adamzu
Copy link

adamzu commented May 19, 2023

hi i'm getting this too and I'm wondering if it's because I implemented the code block in the "Note Reading Keychain Persistence" section. Did either of you who were running into this issue also follow this suggestion? I think it might be the problem described here - https://stackoverflow.com/questions/20269116/nsuserdefaults-losing-its-keys-values-when-phone-is-rebooted-but-not-unlocked. I'm going to try and disable this code and see if the problem is fixed

@billnbell
Copy link

did it work?

@adamzu
Copy link

adamzu commented May 20, 2023

Need a few more days to gather data and will circle back

@billnbell
Copy link

I did not implement that. I am still getting the problem - when coming from background to foreground I dont have the saved info.

I was going to try below but several people did not say it worked- one person said it worked.

- (void) applicationProtectedDataDidBecomeAvailable:(UIApplication *)application {
  NSLog(@"Application Protected Data Did Become Available");
  [NSUserDefaults resetStandardUserDefaults];
}

@leevlad
Copy link

leevlad commented Jun 20, 2023

I have seen this happen quite often, and for quite a while in our app too. We don't have a good way of reproducing this yet. Would appreciate if anyone had any suggestions.

@adamzu
Copy link

adamzu commented Jun 20, 2023

We ended up replacing this package with react-native-keychain, which seems to have solved the problem. My theory for the problem my team was facings is that on iOS, this package by default writes data to the keychain with a accessibility state that only allows the React Native app t load the secure data when the phone is unlocked (see here - https://developer.apple.com/documentation/security/keychain_services/keychain_items/restricting_keychain_item_accessibility#2974972). For us, this was problematic, because when a user received a notification while their phone was locked (e.g. was in their pocket), the app would start in the background, attempt to load the auth data, and be denied access. react-native-keychain let us use set the data accessibility option to 'Always Accessible' which got around this issue (albeit at some security risk, but it was acceptable for our purposes).

Not sure if that's what's happening for anyone else here, but figured I would share. Hope this helps!

@leevlad
Copy link

leevlad commented Jun 20, 2023

Thanks for taking the time to reply here @adamzu, that is helpful.

While we don't make any attempts to access app state when the device is locked, I suspect there might be other scenarios that cause the app to attempt to load the store before the keychain is ready.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants