How to sync data upon opening the app?
Question
Application Type
Mobile

Hi, I am creating a mobile application with offline functionalities.

Scenario:

-Login

-Close the app

-Open the app

-Create records (offline)

-Close the app

-Open the app (now online)

-*(I want to sync my created records to the server)\

-Load the updated list

For what I understand, the SyncOnLogin only executes when I'm logging in, but I'm already logged in when I opened the app so this does not trigger it. SyncOnOnline triggers when the app is already opened and the network status changed. SyncOnResume triggers when the app is on the background and you switched back to the app, but I closed the app so these 2 does not trigger it.

I can run TriggerOfflineDataSync in OnInitialize of my home screen but I'm not sure if this is the correct way to do this.

Solution

Hi Kenneth1,

You have the system event On_Application_Ready, it might fit your need.

Perhaps be careful to not double sync and avoid extra work.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Platform_Utilities/System_Events/Mobile/On_Application_Ready

Hope it helps

This is interesting I've only seen this now, I think this might work in my case. What are the common use cases for this Client action?

Hello Kenneth,

Your understanding of the Sync options is correct, however, if you change the Network status while the app is in the background, once you return to the app this should trigger the OnResume event.

Here is some more information about Data Sync Patterns in Outsystems: 

Offline Data Sync Patterns 

Implementing Offline Sync

Offline Data Sync Patterns - Forge 

Hope it helps!

Paulo Rosário

But there are scenarios that might change network status when the app is not in the background so this does not accommodate it I think?

Solution

Hi Kenneth1,

You have the system event On_Application_Ready, it might fit your need.

Perhaps be careful to not double sync and avoid extra work.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Platform_Utilities/System_Events/Mobile/On_Application_Ready

Hope it helps

This is interesting I've only seen this now, I think this might work in my case. What are the common use cases for this Client action?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.