Rocket.Chat.ReactNative
Rocket.Chat.ReactNative copied to clipboard
Some iOS 16 phones do not save session
Description:
We have updated our white-label app from version 4.35.1 (or 4.27.1) to version 4.40.0 and now after closing the app users are forced to login every time.
We found two solutions:
- Reinstall the application (not suitable due to the large number of users)
- Use new instance name for MMKV container (our current solution)
I think the problem is that our users upgraded the iOS 16 first and only then we released a new version of the app and ran into the problem of changing the default accessibility level (and there) or just because of new accessibility level. So we had to migrate the data.
We've changed two files, but we're not sure if that completely solves the problem.
diff --git a/app/lib/methods/userPreferences.ts b/app/lib/methods/userPreferences.ts
index f9b82dec4..c72275356 100644
--- a/app/lib/methods/userPreferences.ts
+++ b/app/lib/methods/userPreferences.ts
@@ -1,9 +1,13 @@
import { create, MMKVLoader, MMKVInstance, ProcessingModes, IOSAccessibleStates } from 'react-native-mmkv-storage';
+import { isIOS } from './helpers';
+
const MMKV = new MMKVLoader()
// MODES.MULTI_PROCESS = ACCESSIBLE BY APP GROUP (iOS)
.setProcessingMode(ProcessingModes.MULTI_PROCESS)
.setAccessibleIOS(IOSAccessibleStates.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY)
+ // https://github.com/ammarahm-ed/react-native-mmkv-storage/pull/263
+ .withInstanceID(isIOS ? 'encrypted' : 'default')
.withEncryption()
.initialize();
diff --git a/ios/Shared/RocketChat/Storage.swift b/ios/Shared/RocketChat/Storage.swift
index 7f2496897..029e22159 100644
--- a/ios/Shared/RocketChat/Storage.swift
+++ b/ios/Shared/RocketChat/Storage.swift
@@ -19,7 +19,7 @@ class Storage {
final var mmkv: MMKV? = nil
init() {
- let mmapID = "default"
+ let mmapID = "encrypted" // https://github.com/ammarahm-ed/react-native-mmkv-storage/pull/263
let instanceID = "com.MMKV.\(mmapID)"
let secureStorage = SecureStorage()
Can you please tell me how to solve this problem completely?
Environment Information:
- Rocket.Chat Server Version: 6.4.1
- Rocket.Chat App Version: 4.40.0
- Device Name: iOS
- OS Version: 16