flutter_secure_storage icon indicating copy to clipboard operation
flutter_secure_storage copied to clipboard

[Urgent] Saved data automatically removed after 2,3 hours from Android and IOS devices.

Open MohsinIkram-Auxilium opened this issue 1 year ago • 6 comments

I'm using this package. It is working fine for short time. I observed after few hours, all data cleaned up from the secure storage. Most of our users are facing the issue. Need your urgent support. Thanks

Here is the class I'm using : `class SecureStorageManager { static SecureStorageManager? _instance; late FlutterSecureStorage _storage; bool _initialized = false;

SecureStorageManager._internal();

factory SecureStorageManager() { _instance ??= SecureStorageManager._internal(); return _instance!; }

Future initialize() async { if (!_initialized) { _storage = const FlutterSecureStorage( aOptions: AndroidOptions( encryptedSharedPreferences: true, // Secure preferences on Android ), // iOptions: IOSOptions( // accessibility: KeychainAccessibility.first_unlock, // Secure Keychain on iOS // ), ); _initialized = true; } }

Future setString(String key, String value) async { try { await _storage.write(key: key, value: value); } catch (e) { Debugger.log('Error writing value: $e'); } }

Future<String?> getString(String key) async { try { return await _storage.read(key: key); } catch (e) { Debugger.log('Error reading value: $e'); return null; } } }`

MohsinIkram-Auxilium avatar Sep 26 '24 07:09 MohsinIkram-Auxilium

Please add what motivates you to think that saved data removed after 2,3 hours. Add some proof too.

sumitsharansatsangi avatar Sep 26 '24 09:09 sumitsharansatsangi

@sumitsharansatsangi I am saving my auth data into secure storage at login. I'm only removing data on the logout button. But when I logged in and open app after few hours, all my auth data removed from the secured storage. This is only happened when I'm not opened the App after an hours. The main point is you can check the issues, many developers complaining same issue they lost their data.

MohsinIkram-Auxilium avatar Sep 26 '24 10:09 MohsinIkram-Auxilium

Many who? Please provide some hard proof? I have never experienced losing saved data either on android or ios? It's either a coding issue on your end (some other parts of your code deleted those data) or it's a device specific issue. I know some devices which came preinstalled with 'clean master' or similar app, which periodically 'clean' your phone.

Daniel-Cong avatar Sep 27 '24 02:09 Daniel-Cong

@MohsinIkram-Auxilium, Don't put what class you are using , instead put your code, you implementation. If you are hesitating about putting your code make the class name or function name or variable name generic and then put the code. Another easy way is to do self assessment of the issue by running the example code of this package, see whether you receive the same issue or not on your multiple devices. if the issue still persist then it will be a device specific issue, then mention the model, company and other information of that device, here. If the issue doesn't persist with the example code and your code is the culprit, Paste the code after doing said modification.

sumitsharansatsangi avatar Sep 27 '24 05:09 sumitsharansatsangi

@Daniel-Cong I have Google Pixal 4a(5G) device. @sumitsharansatsangi I'm creating a demo project. I will share the link in this thread.

MohsinIkram-Auxilium avatar Sep 27 '24 07:09 MohsinIkram-Auxilium

Hi @Daniel-Cong @sumitsharansatsangi, I have implemented my existing code into seperate project and try to find out the issue why my data is removing after some time. So I have figured out it. Basically my app is auth based and our session timeout is only one week. After one week we are expiring our token from the backend side and when in APIs when we are getting Expire Token exception then we are clearing the app data.

So unfortunatly due to some reasons there was a bug from the backend side. Our token was expiring after 2,3 hours. So every time when user open the app after long time, he always moved to login page.

So I apologised to you. Your package is working great. Thanks for your swift and kind support.

MohsinIkram-Auxilium avatar Sep 30 '24 07:09 MohsinIkram-Auxilium

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] avatar Nov 30 '24 02:11 github-actions[bot]