Describe the bug
Loading an existing storage instance using a custom encryption key causes the app to crash if secure storage is not used.
To Reproduce
Use the following code:
const myStorage = new MMKVLoader()
.withInstanceID('myInstanceId')
.withEncryption()
.encryptWithCustomKey(`myEncryptionKey`, false)
.initialize();
Expected behavior
The storage is initialized the first time it is run. However, if you restart the app and initialize the storage again, the app exits immediately. I expect the storage to load without crashing.
Platform Information:
OS: Android (did not try iOS)
React Native Version: 0.67.3
Library Version: 0.7.6
Additional context
I did some troubleshooting and found that this line of code in initializer.js is the last line that runs before the crash: var key = mmkvJsiModule.getSecureKey(options.alias); (inside initWithEncryptionUsingOldKey). It seems it's trying to load the key from secure storage even though the secure storage boolean was set to false.
Describe the bug Loading an existing storage instance using a custom encryption key causes the app to crash if secure storage is not used.
To Reproduce Use the following code:
Expected behavior The storage is initialized the first time it is run. However, if you restart the app and initialize the storage again, the app exits immediately. I expect the storage to load without crashing.
Platform Information:
Additional context I did some troubleshooting and found that this line of code in
initializer.js
is the last line that runs before the crash:var key = mmkvJsiModule.getSecureKey(options.alias);
(insideinitWithEncryptionUsingOldKey
). It seems it's trying to load the key from secure storage even though the secure storage boolean was set to false.