Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MohsinIkram-Auxilium opened this issue Sep 26, 2024 · 7 comments
Labels

Comments

@MohsinIkram-Auxilium
Copy link

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;
}
}
}`

@sumitsharansatsangi
Copy link

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

@MohsinIkram-Auxilium
Copy link
Author

@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.

@Daniel-Cong
Copy link

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.

@sumitsharansatsangi
Copy link

sumitsharansatsangi commented Sep 27, 2024

@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.

@MohsinIkram-Auxilium
Copy link
Author

@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
Copy link
Author

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.

Copy link

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

@github-actions github-actions bot added the stale label Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants