5
Views
5
Comments
Mobile offline data sync without a valid session
Application Type
Mobile

Hi,


I have an issue where my local data were sent without a valid session.

The general steps:

  1. Insert some data while in offline mode.
  2. Kill the app.
  3. Wait until the Max Idle Time of the persistent login setting has passed (for testing, I set it to be 1 day).
  4. Open the app in online mode.

In this scenario, I found the offline data sync has started in the background during app start. Clicking any button in the UI redirects me to login screen (which means the session is not valid, but somehow the data have been sent through)

As far as I know, the session is validated when calling any server action, so in this case the security exception should be raised and the sync can be stopped as well. I'm not sure where is the missing part: All pages have anonymous role unchecked and the security exception has been handled in the global exception handler.

I have also tried to use IF block below in the sync action, but no luck.

GetUserId() <> NullIdentifier()


Any idea?



Thank you.


Cheers,

Kadek

Hi Kadek,

Can you please provide your OfflineDataSyncConfiguration?

Thank you and regards,

Chris

Hi Chris,

Here is my OfflineDataSyncConfiguration:

  • SyncOnOnline = True
  • SyncOnLogin = True
  • SyncOnResume = True
  • RetryOnError = False


Regards,

Kadek

Hi Kadek,

Thank you for the information.

Apologies but I can't seem to find a documentation that would automatically discard the pending units of the offline sync despite of no current session exists. I'm guessing you have to manually discard it.

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Offline/Sync_Framework_Reference#OfflineDataSync

Hope this helps.

Thank you and kind regards,

Chris

No worries Chris,

Thanks for the reply, appreciate it.

Anyway do you know how to check whether the current session is still exist or not?


Regards,

Kadek

Hi Kadek,

As far as i know, the above condition may not work in some scenarios for mobile, but please make sure it's encapsulated within a Server action.

These are some good read to:

https://www.outsystems.com/forums/discussion/13643/understanding-the-outsystems-session-model/

https://www.outsystems.com/forums/discussion/44063/getuserid-mobile-cached-want-to-check-if-user-is-logged-in/

Thank you and kind regards,

Chris