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

After reopen application, getting null values in IOS. But working in Android. #752

Closed
sureshprokraya opened this issue Jul 10, 2024 · 10 comments

Comments

@sureshprokraya
Copy link

Hi,
I am using flutter_secure_storage: 9.0.0 version in flutter application. But when ever i closed the app and reopen again ,
After splash screen i am getting data null in IOS, but in Android works fine.

How to fix this issue, please any one help me on this.

@sureshprokraya sureshprokraya changed the title After reopen app, getting null values in IOS. After reopen application, getting null values in IOS. But working im Android. Jul 10, 2024
@sureshprokraya sureshprokraya changed the title After reopen application, getting null values in IOS. But working im Android. After reopen application, getting null values in IOS. But working in Android. Jul 10, 2024
@sureshprokraya
Copy link
Author

class SecureStorage {
// Create storage
late FlutterSecureStorage _storage;

static final SecureStorage _instance = SecureStorage._internal();

factory SecureStorage() {
return _instance;
}

SecureStorage._internal() {
_storage = FlutterSecureStorage();
}

// Read value
Future isSet({required String key}) async {
var val = await _storage.containsKey(key: key);
return val;
}

// Read value
Future readSecureData({required String key}) async {
var readData = await _storage.read(key: key);
return readData;
}

// Read all values
Future readAllSecureData() async {
Map<String, String> allValues = await _storage.readAll();
return allValues;
}

// Write value
Future writeSecureData({required String key, required String value}) async {
var writeData =
await _storage.write(key: key, value: value);
return writeData;
}

// Delete value
Future deleteSecureData({required String key}) async {
var deleteData = await _storage.delete(key: key);
return deleteData;
}

// Delete value
Future deleteAllSecureData() async {
var deleteData = await _storage.deleteAll();
return deleteData;
}
}
//This is I am using in my app, but still issue is not fixed.

@sureshprokraya
Copy link
Author

I am updated secure storage v9.0.0 to v9.2.2, then again same issue:
I got this Error after app close and reopen:

PlatformException(Unexpected security result code, Code: -25300, Message: The specified item could not be found in the keychain., -25300, null)--

Please any one have solution for this.

@sureshprokraya
Copy link
Author

Every time i am calling the Login API for token update, and deleting all Secure Stotage data, then again saving fresh data in secure storage.

So when ever reopen the application in IOS app,
When ever try to save data in secure storage below error occurred
How to solve this.

@kkh975
Copy link

kkh975 commented Jul 23, 2024

Same here, is there a size limit?

my code:

class LocalStorageServiceSecureImpl {
  late final FlutterSecureStorage _storage;

  LocalStorageServiceSecureImpl() {
    _storage = FlutterSecureStorage(
      iOptions: _getIOSOptions,
      aOptions: _getAndroidOptions,
    );
  }

  AndroidOptions get _getAndroidOptions =>
      const AndroidOptions(encryptedSharedPreferences: true);

  IOSOptions get _getIOSOptions => const IOSOptions(
        accessibility: KeychainAccessibility.first_unlock,
        synchronizable: true,
      );

  Future<void> saveData(String key, String data) async {
    await _storage.write(
      key: key,
      value: data,
      iOptions: _getIOSOptions,
      aOptions: _getAndroidOptions,
    );
  }

  Future<String?> loadData(String key) async {
    return await _storage.read(
      key: key,
      iOptions: _getIOSOptions,
      aOptions: _getAndroidOptions,
    );
  }
}

@sureshprokraya
Copy link
Author

sureshprokraya commented Jul 23, 2024 via email

@huvi8161
Copy link

I have the same problem.

@kieranmccwayleadr
Copy link

We have this issue along with the BadPaddingException: #541 I feel we need to personally remove the Flutter Secure Storage. It's causing weird issues. Might look into flutter_keychain @sureshprokraya what has been your experience so far using this package across android and ios?

@rddewan
Copy link

rddewan commented Jul 25, 2024

value is always null

@sureshprokraya
Copy link
Author

sureshprokraya commented Jul 25, 2024 via email

@rddewan
Copy link

rddewan commented Jul 25, 2024

Look like it only support string as a value. I tries to store a int and got error but after storing as string its working

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

No branches or pull requests

5 participants