Offline local data lost on closing native app

How to set up a nanoflow as background service to wind up things when user closes the app. Some data is generated in app and stored offline in local database. When users close the app or put it in background, I want to synchronize all the data so its safe for next time. How to do that without any user action to trigger synchronize (sync button or nanoflow on button click etc) Currently I can sync data with a button (user action), but unable to do it automatically at specified intervals or just before app is closed. 
1 answers


In Project » Settings » Runtime  you can call a Microflow before shutdown which can commit the data locally.