mogol / flutter_secure_storage

A Flutter plugin to store data in secure storage
https://pub.dartlang.org/packages/flutter_secure_storage
BSD 3-Clause "New" or "Revised" License
1.09k stars 340 forks source link

I suspect a bug where my session keys are deleted and it causes my session to be logged out. #700

Closed nicolasvahidzein closed 1 month ago

nicolasvahidzein commented 2 months ago

I have been monitoring my client apps and something is going on iOS that after a few minutes, the token stored in the secure storage using this pluggin gets deleted without the only function allowed to delete those entries is called.

This all points to the fact that the keys are deleted on their own or that the secure storage gets reset.

2024-04-23 22:58:51 token is present 2024-04-23 23:01:06 token is no longer present 3 seconds later

How would i find this out?

2024-04-23 22:58:51.065757 INFO [_AppStore:_monitorToken] DataLogType.NONE -> accessToken round 3 at moment (2024-04-23 22:58:51.065371):  

2024-04-23 22:58:51.066548 INFO [_AppStore:_monitorToken] DataLogType.NONE -> eyJ0eX  

2024-04-23 22:58:53.173764 INFO [_HomeInitializedWidgetState:_checkAppUpdates] DataLogType.NONE -> _checkAppUpdates function inside home_initialized_widget.dart  

2024-04-23 22:58:53.175025 INFO [UserRepository:retrieveHiveSetting] DataLogType.NONE -> retrieveHiveSetting function inside user_repository.dart  

2024-04-23 22:58:53.176022 INFO [UserRepository:retrieveHiveSetting] DataLogType.NONE -> retrieveHiveSetting function inside user_repository.dart  

2024-04-23 22:58:53.176933 INFO [UserRepository:retrieveHiveSetting] DataLogType.NONE -> retrieveHiveSetting function inside user_repository.dart  

2024-04-23 22:58:53.177803 INFO [_HomeInitializedWidgetState:_checkAppUpdates] DataLogType.NONE -> appUpdateAvailable: true  

2024-04-23 22:58:53.178639 INFO [_HomeInitializedWidgetState:_checkAppUpdates] DataLogType.NONE -> appUpdateAvailableDismissed: true  

2024-04-23 22:58:53.179515 INFO [_HomeInitializedWidgetState:_checkAppUpdates] DataLogType.NONE -> do not show the update dialog  

2024-04-23 22:58:56.841885 INFO [_AppState:_checkConnection] DataLogType.NONE -> _checkConnection function inside main.dart  

2024-04-23 22:58:56.843435 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> _processConnectivityResults function inside main.dart  

2024-04-23 22:58:56.844012 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> there is wifi connectivity  

2024-04-23 22:58:56.844576 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> there is INDEED connectivity  

2024-04-23 22:58:56.845095 INFO [_AppState:_testPing] DataLogType.NONE -> _testPing function inside main.dart  

2024-04-23 22:58:56.945443 INFO [_AppState:_testPing] DataLogType.NONE -> lookup results:  

2024-04-23 22:58:56.946042 INFO [_AppState:_testPing] DataLogType.NONE -> PingResponse(seq:0, ip:142.251.47.206, ttl:116, time:95.638 ms)  

2024-04-23 22:58:56.946493 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> ping test was successful we can exit this loop and function  

2024-04-23 22:58:56.947021 INFO [_AppState:_connectionChanged] DataLogType.NONE -> _connectionChanged function inside main.dart  

2024-04-23 22:58:56.947560 INFO [_AppState:_connectionChanged] DataLogType.NONE -> CONNECTED  

2024-04-23 22:59:04.417893 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> didChangeAppLifecycleState function inside home_view.dart  

2024-04-23 22:59:04.419131 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> inactive case  

2024-04-23 22:59:06.078432 INFO [_AppStore:_monitorToken] DataLogType.NONE -> accessToken round 4 at moment (2024-04-23 22:59:06.078104):  

2024-04-23 22:59:06.079201 INFO [_AppStore:_monitorToken] DataLogType.NONE -> eyJ0eX  

2024-04-23 22:59:06.079777 INFO [_AppStore:_checkLogs] DataLogType.NONE -> log mode is INDEED enabled  

2024-04-23 22:59:06.434231 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> didChangeAppLifecycleState function inside home_view.dart  

2024-04-23 22:59:06.434394 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> resumed case  

2024-04-23 22:59:06.434628 INFO [DevicePermissions:checkLocationPermission] DataLogType.NONE -> checkLocationPermission function inside device_permissions.dart  

2024-04-23 22:59:06.434820 INFO [DevicePermissions:checkLocationPermission] DataLogType.NONE -> mode: whenInUse  

2024-04-23 22:59:06.434993 INFO [_AppStore:getLastNotificationResumedAppLifecycleCheck] DataLogType.NONE -> _lastSystemNotificationCheck cannot be null here  

2024-04-23 22:59:06.435125 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> last notification check was MORE than 30 seconds ago  

2024-04-23 22:59:06.435268 INFO [_AppStore:getMomentWeReturnedToApp] DataLogType.NONE -> _leftApp cannot be null here  

2024-04-23 22:59:06.435398 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> we left the app for MORE than 30 seconds  

2024-04-23 22:59:06.435538 INFO [NotificationsRepository:retrieveNotifications] DataLogType.NONE -> retrieveNotifications function inside notifications_repository.dart  

2024-04-23 22:59:06.435679 INFO [NotificationsRepository:retrieveNotifications] DataLogType.NONE -> currentNumNotifications: 0  

2024-04-23 22:59:06.435828 INFO [UserRepository:retrieveAppCountry] DataLogType.NONE -> retrieveAppCountry function inside user_repository.dart  

2024-04-23 22:59:06.435975 INFO [HttpRequestHandler:getBaseUrl] DataLogType.NONE -> getBaseUrl function inside http_request_handler.dart  

2024-04-23 22:59:06.436119 INFO [HttpRequestHandler:getBaseUrl] DataLogType.NONE -> country: congo  

2024-04-23 22:59:06.436264 INFO [UserRepository:retrieveToken] DataLogType.NONE -> retrieveToken function inside user_repository.dart  

2024-04-23 22:59:06.436761 INFO [DevicePermissions:checkNotificationsPermission] DataLogType.NONE -> checkNotificationsPermission function inside device_permissions.dart  

2024-04-23 22:59:06.436908 INFO [_AppStore:_checkLogs] DataLogType.NONE -> logFileSize:  

2024-04-23 22:59:06.436981 INFO [_AppStore:_checkLogs] DataLogType.NONE -> 492.7275390625  

2024-04-23 22:59:06.437040 INFO [_AppStore:_checkLogs] DataLogType.NONE -> size is smaller than the threshhold, do nothing  

2024-04-23 22:59:06.437939 INFO [_AppStore:checkPermissionsStatus] DataLogType.NONE -> geoLocationPermissionStatus is the same  

2024-04-23 22:59:06.438017 INFO [_AppStore:checkPermissionsStatus] DataLogType.NONE -> notificationsPermissionStatus is the same  

2024-04-23 22:59:06.438082 INFO [_AppStore:checkPermissionsStatus] DataLogType.NONE -> gpsEnabled is the same  

2024-04-23 22:59:06.444256 INFO [UserRepository:retrieveToken] DataLogType.NONE -> accessToken:  

2024-04-23 22:59:06.444352 INFO [UserRepository:retrieveToken] DataLogType.NONE -> eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiZWI2OGFlMWY1YjBiOGQ0OGIzYWU1NGZiMTA3NjRlOTU4NzI3NDVhZjU0ZTZmZjQ4ZTg0MWRlZDJhYWM1NjJlY2Q3NzRkOTQwMGVhYTE4Y2UiLCJpYXQiOjE3MTM5MDg4MzIuNjAwMjUyLCJuYmYiOjE3MTM5MDg4MzIuNjAwMjU4LCJleHAiOjE3MTkwOTI4MzIuNTgxNDAxLCJzdWIiOiI4Iiwic2NvcGVzIjpbXX0.EgmuuqQVpChsMcQzMNAYggC8p8XZ70xad8s6CIrgR9opni58Trp0-XiPX56AxhPnvzq6NlLUdzMe-WHPo8-23mZxR8LSVSKMwOsmeLcadVpUhgpuItR-Ul3v4VnIS3_pxbkq3wGaVqtCsYufPVnbO7Vn9kZWMSd0iunKxm5tS-2jBfX0KKV3nwTnxT2_4QTUX2ew-FdzRyfEHqfcTGCWl24MfyvjnG789OKKzx6eD_tLSLQcU5ZDN9U0YAs1jazhcJx6tgTT78X4IArHniU4AOf_NO2JiTfNFBfZJYP0wNCokssEnOr9kB9L8gdVteJpl0YKupp7IBcLPoI9tFLhJxMckiXae_yHGPffteCWPUTHHpYyS7ZQ0LZ-b5C4yiXPLbaA7bklHehvtFxg8Qhhgp5CHbUFEDY_EUXhf1kerJBQs17Um1CkXDRHQ1U5ohy2jCA1Z4MuPc2r244Yo6-hJgQWA9LThqeIA_a6SOoDOmKK7r7DGozvjfyWejom_Dx1r5jpd2TMLDsofCfm-WreaLOfbIbJV1fWz_yf-sUc7wMRIRIWT_XFC0WkV4fFBtOfp-QvTm-_lWJP7969sqA35p3eI6XgxPnn8dwCTZokQ0kyANuZsBP-WkFsMaxhX4rM7s_F88Dg4NxUFpGtFtI9mKciPMSu6APHxsBgwT440Ws  

2024-04-23 22:59:06.444426 INFO [UserRepository:retrieveToken] DataLogType.NONE -> refreshToken:  

2024-04-23 22:59:06.444498 INFO [UserRepository:retrieveToken] DataLogType.NONE -> def50200f839fd417aa99b86bab204dd3d779b3f0d628b9af0a4071aa90742ebc07e6f2c8cb38564177483cc4ab63cdc4663d66b974391cc75c7c438f8d014d160cb2c760dbe94fa0c872e7ddf009ce12e5c7f1a469358e5a7156b04c593e20048368b6e2c7082debd3cf6a8de7d6fbc598954cd86a57f5ff452f79058a2eb75c4598eb3403837ad163a29dc48ea9e136576c67496220f1aa00da295be82afb1eb6e37ea19cb97d9c41334578a72b8c5b97ff128914c04c5b3bda10b64843d5bde1e6130a6a262c1d143178c7ce44b211a9fddc0d07ff4717378de937b56f85ab54f95039a7ec20ce02fb8add2b95acb257080dc2b2092a6e1ca2f62771de09c6edd6ebdabb645be8ee2af4f9c0bb1de184e225239971c852cc12da7f7c329a7b6b7e8d000539c292d6a21fc639f51d27ec91216d2566696fea422c6fa5e003d7391f92f77dc2e953407598d31bd9214463193d022eb74366e27464a539855f392  

2024-04-23 22:59:06.444573 INFO [UserRepository:retrieveToken] DataLogType.NONE -> tokenExpiration:  

2024-04-23 22:59:06.444654 INFO [UserRepository:retrieveToken] DataLogType.NONE -> 1719092832000  

2024-04-23 22:59:06.444727 INFO [UserRepository:retrieveToken] DataLogType.NONE -> tokenType:  

2024-04-23 22:59:06.444793 INFO [UserRepository:retrieveToken] DataLogType.NONE -> Bearer  

2024-04-23 22:59:06.444854 INFO [NotificationsRepository:retrieveNotifications] DataLogType.NONE -> this is the endpointUrl: https://cg.zandu.biz:8039/api/mobile_admin/v1.0/notifications/get-extra-notifications  

2024-04-23 22:59:06.444920 INFO [UserRepository:retrieveHiveSetting] DataLogType.NONE -> retrieveHiveSetting function inside user_repository.dart  

2024-04-23 22:59:07.800903 INFO [QueryResponseAnalyzer:checkQueryResponse] DataLogType.NONE -> checkQueryResponse function inside query_response_analyzer.dart  

2024-04-23 22:59:07.801774 INFO [NotificationsRepository:retrieveNotifications] DataLogType.NONE -> data:  

2024-04-23 22:59:07.802327 INFO [NotificationsRepository:retrieveNotifications] DataLogType.NONE -> totalLocalNotifications: 1  

2024-04-23 22:59:07.802809 INFO [NotificationsRepository:retrieveNotifications] DataLogType.NONE -> totalNotifications: 1  

2024-04-23 22:59:07.803317 INFO [NotificationsRepository:retrieveNotifications] DataLogType.NONE -> we CANNOT request more notifications from the backend  

2024-04-23 22:59:07.803965 INFO [NotificationsRepository:updateNotifications] DataLogType.NONE -> updateNotifications function inside notifications_repository.dart  

2024-04-23 22:59:07.804526 INFO [NotificationsRepository:updateNotifications] DataLogType.NONE -> newNotifications: [{UID: 2f7e24aa-0850-44b3-82c0-2f917cdf3874, foreignUID: 04e6ec4c-5af3-4941-9de9-07ff236d8cb3, title: Bienvenue sur Zandu, subtitle: Merci pour votre confiance et dites nous si vous avez des questions., asset_type: image, icon: null, image: /images/placeholders/welcomenotification/welcome.jpg, account_type: partner, read_status: true, status: active, created_at: 2023-06-25 08:03:51, updated_at: 2023-06-25 08:07:01}]  

2024-04-23 22:59:07.805082 INFO [NotificationsRepository:updateNotifications] DataLogType.NONE -> appendMode: false  

2024-04-23 22:59:07.805534 INFO [NotificationsRepository:updateNotifications] DataLogType.NONE -> index: 0  

2024-04-23 22:59:07.805952 INFO [NotificationsRepository:updateNotifications] DataLogType.NONE -> tempNotifications:  

2024-04-23 22:59:07.806376 INFO [NotificationsRepository:updateNotifications] DataLogType.NONE -> [{UID: 2f7e24aa-0850-44b3-82c0-2f917cdf3874, foreignUID: 04e6ec4c-5af3-4941-9de9-07ff236d8cb3, title: Bienvenue sur Zandu, subtitle: Merci pour votre confiance et dites nous si vous avez des questions., asset_type: image, icon: null, image: /images/placeholders/welcomenotification/welcome.jpg, account_type: partner, read_status: true, status: active, created_at: 2023-06-25 08:03:51, updated_at: 2023-06-25 08:07:01}]  

2024-04-23 22:59:07.813935 INFO [_NotificationsButtonWidgetState:_isNotificationsCountVisible] DataLogType.NONE -> _isNotificationsCountVisible function inside notifications_button.dart  

2024-04-23 22:59:07.814702 INFO [_NotificationsButtonWidgetState:_isNotificationsCountVisible] DataLogType.NONE -> notificationCount:  

2024-04-23 22:59:07.815330 INFO [_NotificationsButtonWidgetState:_isNotificationsCountVisible] DataLogType.NONE -> notificationCount  

2024-04-23 22:59:07.815973 INFO [_NotificationsButtonWidgetState:_isNotificationsCountVisible] DataLogType.NONE -> notification count is LESS than 0  

2024-04-23 22:59:11.115126 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> didChangeAppLifecycleState function inside home_view.dart  

2024-04-23 22:59:11.115628 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> inactive case  

2024-04-23 22:59:11.148473 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> didChangeAppLifecycleState function inside home_view.dart  

2024-04-23 22:59:11.148904 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> hidden case  

2024-04-23 22:59:11.149141 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> didChangeAppLifecycleState function inside home_view.dart  

2024-04-23 22:59:11.149368 INFO [_HomeViewState:didChangeAppLifecycleState] DataLogType.NONE -> paused case  

2024-04-23 22:59:11.841347 INFO [_AppState:_checkConnection] DataLogType.NONE -> _checkConnection function inside main.dart  

2024-04-23 22:59:11.842980 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> _processConnectivityResults function inside main.dart  

2024-04-23 22:59:11.843653 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> there is wifi connectivity  

2024-04-23 22:59:11.844207 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> there is INDEED connectivity  

2024-04-23 22:59:11.844804 INFO [_AppState:_testPing] DataLogType.NONE -> _testPing function inside main.dart  

2024-04-23 22:59:11.921815 INFO [_AppState:_testPing] DataLogType.NONE -> lookup results:  

2024-04-23 22:59:11.922474 INFO [_AppState:_testPing] DataLogType.NONE -> PingResponse(seq:0, ip:142.251.47.206, ttl:116, time:72.926 ms)  

2024-04-23 22:59:11.922972 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> ping test was successful we can exit this loop and function  

2024-04-23 22:59:11.923525 INFO [_AppState:_connectionChanged] DataLogType.NONE -> _connectionChanged function inside main.dart  

2024-04-23 22:59:11.924093 INFO [_AppState:_connectionChanged] DataLogType.NONE -> CONNECTED  

2024-04-23 23:01:06.332583 INFO [_AppStore:cronTick] DataLogType.NONE -> cronTick event  

2024-04-23 23:01:06.333083 INFO [_AppStore:_monitorToken] DataLogType.NONE -> _monitorToken function  

2024-04-23 23:01:06.333419 INFO [UserRepository:checkTokenValidity] DataLogType.NONE -> checkTokenValidity function inside user_repository.dart  

2024-04-23 23:01:06.333641 INFO [_AppState:_checkConnection] DataLogType.NONE -> _checkConnection function inside main.dart  

2024-04-23 23:01:06.341637 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> _processConnectivityResults function inside main.dart  

2024-04-23 23:01:06.341814 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> there is wifi connectivity  

2024-04-23 23:01:06.341941 INFO [_AppState:_processConnectivityResults] DataLogType.NONE -> there is INDEED connectivity  

2024-04-23 23:01:06.342060 INFO [_AppState:_testPing] DataLogType.NONE -> _testPing function inside main.dart  

2024-04-23 23:01:06.346936 INFO [_AppStore:_monitorToken] DataLogType.NONE -> accessToken round 1 at moment (2024-04-23 23:01:06.346843):  

2024-04-23 23:01:06.347106 INFO [_AppStore:_monitorToken] DataLogType.NONE -> null

2024-04-23 23:01:06.347222 INFO [_AppStore:_monitorToken] DataLogType.NONE -> accessToken round 1 at moment (2024-04-23 23:01:06.346843):  

2024-04-23 23:01:06.347328 INFO [_AppStore:_monitorToken] DataLogType.NONE -> null  

2024-04-23 23:01:06.347516 INFO [UserRepository:checkTokenValidity] DataLogType.NONE -> retrieveAccessTokenFromSecureStorage:  

2024-04-23 23:01:06.347638 INFO [UserRepository:checkTokenValidity] DataLogType.NONE -> null  

2024-04-23 23:01:06.347763 INFO [UserRepository:checkTokenValidity] DataLogType.NONE -> does not have token  
nicolasvahidzein commented 2 months ago

I think i figured it out by reading many of these issues. It is related to the iOS keychain. I added the ios permissions when i write the keys like so. I hope it helps. I will revert back in a few weeks.


        //define the storage
        const secureStorage = FlutterSecureStorage();

        const optionsIos = IOSOptions(accessibility: KeychainAccessibility.first_unlock);

        //Write value
        //linked resource LR_000017
        await secureStorage.write(key: 'accessToken', value: accessToken, iOptions: optionsIos);
        await secureStorage.write(key: 'refreshToken', value: refreshToken, iOptions: optionsIos);
        await secureStorage.write(key: 'tokenExpiration', value: expirationDate.millisecondsSinceEpoch.toString(), iOptions: optionsIos);
        await secureStorage.write(key: 'tokenType', value: tokenType, iOptions: optionsIos);
justprodev commented 1 month ago

@nicolasvahidzein Hi

Can you confirm that first_unlock helped?

Thanks.

nicolasvahidzein commented 1 month ago

Hey @justprodev its hard to tell. I think its good but i do not know how to make a test to be sure.

HHJari commented 1 month ago

Hi,

We have this same issue on iOS, data is being lost sometimes for users.

Could it perhaps be that if users opens the iOS app from PUSH NOTIFICATION, from lock screen, the app opens and plugin thinks phone is still locked and cannot read the data? Some race condition perhaps?

We will be trying that first_unlock option as well for our next update.

nicolasvahidzein commented 1 month ago

@HHJari Hey Jari, that is most definitely it, my issues are completely gone now.

nicolasvahidzein commented 1 month ago

you can skype me (nzein19) if you have any issues.

HHJari commented 1 month ago

@HHJari Hey Jari, that is most definitely it, my issues are completely gone now.

Thanks for the info!

I'm building hotfix update to iOS as we speak, hopefully can roll it out in next 48h and report next week did it resolve for us.

ksyeoh commented 1 month ago

Hi, I'm currently on flutter_secure_storage: ^9.0.0 and I have a user on iOS app experiencing data lost sometimes when launching the app. From user feedback, closing or reopening the app seems to help alleviate the issue. And this happens especially after the app have been in the background for some time. Is this what you guys have been experiencing?

nicolasvahidzein commented 1 month ago

Hello

yes but not data loss. Its related to data fetch when your app is running but the phone is locked. Change your persist method to first_unlock and you should be fine.

HHJari commented 1 month ago

@HHJari Hey Jari, that is most definitely it, my issues are completely gone now.

Thanks for the info!

I'm building hotfix update to iOS as we speak, hopefully can roll it out in next 48h and report next week did it resolve for us.

Our iOS issues seem to be gone too with first_unlock.

But we also noticed that Android Flutter Secure storage fails sometimes to this:

PlatformException(Exception encountered, write, java.lang.NullPointerException: Attempt to invoke interface method 'byte[] com.it_nomads.fluttersecurestorage.ciphers.StorageCipher.encrypt(byte[])' on a null object reference
    at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.write(SourceFile:28)
    at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(SourceFile:283)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.os.HandlerThread.run(HandlerThread.java:65)
, null)

Seems to be similar than this issue: Issue #200

ksyeoh commented 1 month ago

Sorry, just to double check. The reason why I couldn't fetch the data is because of I didn't set first_unlock to the persist method? So, meaning I just need to set frst_unlock for the write method while the read method remains as it is correct?

nicolasvahidzein commented 1 month ago

@ksyeoh yes. On the next write session to secure storage (for me it was the next time the user logged in to the system) you will see that bug on ios disappear. So do what you need to do to trigger a write of those keys once more. See my post below from a few days ago:

I think i figured it out by reading many of these issues. It is related to the iOS keychain. I added the ios permissions when i write the keys like so. I hope it helps. I will revert back in a few weeks.


      //define the storage
      const secureStorage = FlutterSecureStorage();

      const optionsIos = IOSOptions(accessibility: KeychainAccessibility.first_unlock);

      //Write value
      //linked resource LR_000017
      await secureStorage.write(key: 'accessToken', value: accessToken, iOptions: optionsIos);
      await secureStorage.write(key: 'refreshToken', value: refreshToken, iOptions: optionsIos);
      await secureStorage.write(key: 'tokenExpiration', value: expirationDate.millisecondsSinceEpoch.toString(), iOptions: optionsIos);
      await secureStorage.write(key: 'tokenType', value: tokenType, iOptions: optionsIos);
ksyeoh commented 1 month ago

@nicolasvahidzein Ok noted. The reason I was confused whether is a read or write issue is because @HHJari mentioned the app cannot read the data could be because the phone thinks it's still locked. Anyways, I'll give it try. Thanks!

Hi,

We have this same issue on iOS, data is being lost sometimes for users.

Could it perhaps be that if users opens the iOS app from PUSH NOTIFICATION, from lock screen, the app opens and plugin thinks phone is still locked and cannot read the data? Some race condition perhaps?

We will be trying that first_unlock option as well for our next update.

HHJari commented 1 month ago

@nicolasvahidzein Ok noted. The reason I was confused whether is a read or write issue is because @HHJari mentioned the app cannot read the data could be because the phone thinks it's still locked. Anyways, I'll give it try. Thanks!

Hi, We have this same issue on iOS, data is being lost sometimes for users. Could it perhaps be that if users opens the iOS app from PUSH NOTIFICATION, from lock screen, the app opens and plugin thinks phone is still locked and cannot read the data? Some race condition perhaps? We will be trying that first_unlock option as well for our next update.

At the time I was simply speculating why the issue could happen.

nicolasvahidzein commented 1 month ago

But he is correct in a way. The phone is locked and because you use the wrong key for ios the values are being returned as null when the app fetches.